SWITCH STATEMENTS
A switch statement starts with a variable called the switch value. Each case indicates a possible value for this variable and the code that should run if the variable matches that value.
-
The switch expression is evaluated once.
-
The value of the expression is compared with the values of each case.
-
If there is a match, the associated block of code is executed.
-
If there is no match, the default code block is executed.
At the end of each case is the break keyword.
The Different between If-statement and Switch
The if statement evaluates integer, character, pointer or floating-point type or boolean type. On the other hand, switch statement evaluates only character or an integer datatype.
Loops
Loops chech the condition, if it true a code block will run, then the condition will be checked again if it still true the code block will run again, it repeated until the condition return false.
For Loop
if you want to run the same code over and over again, each time with a different value.
-
Initialization : var i=0;
-
condition : i < 10;
-
statements;
-
update : i++
You will commonly see these two keywords used with loops:
-
Break : causes the termination of the loop and tells the interpreter to go onto the next statement of code outside of the loop.
-
Continue : tells the interpreter to continue with the current iteration, and then check the condition again.
While loop
loops through a block of code as long as a specified condition is true.
Syntax
while(condition)
{
statements;
}
Do While loop
will execute the code block once, before checking if the condition is true, then it will repeat the loop as long as the condition is true.
Syntax
do
{
statements; } while(condition);
Lists
HTML provides us with three different types:
- Ordered lists are lists where each item in the list is numbered.
- Unordered lists are lists that begin with a bullet point .
- Definition lists are made up of a set of terms along with the definitions for each of those terms.
-
Use the HTML <dl element to define a description list.
-
Use the HTML <dt element to define the description term.
-
Use the HTML <dd element to describe the term in a description list.
Box Dimensions
The box-sizing property allows us to include the padding and border in an element’s total width and height.
Border width
- border style
- border width
- border color
- indivisual border side
Padding
properties are used to generate space around an element’s content, inside of any defined borders.
Margin
properties are used to create space around elements, outside of any defined borders.
Centering Content
If you want to center a box on the page (or center it inside the element that it sits in).
inline
This causes a block-level element to act like an inline element.