reading-notes

Reading Notes

View the Project on GitHub simon-panek/reading-notes

Code 201: Class 03 - HTML Lists, CSS Boxes, JS Control Flow


HTML Text: 62-73

Lists

Lists can be nested inside one-another

HTML Text: 300-329

Box Dimensions

Padding, Border, Margin

Border Width

To center a box, set a width value then set margin-left: auto; and margin-right: auto;

Display *display property can change an inline element to a block or vice versa

Visibility

Border Radius

JS Text: 70-73

Arrays special variable that stores a list of values

Array a variable that stores a list of values

JS Text: 162-182

Switch Statement a variable given the switch value is used to indicate which code to run


switch(level) {
    case 'One':
        title = 'Level 1';
        break;
    case 'Two':
        title = 'Level 2';
        break;
    case 'Three':
        title = 'Level 3';
        break;
    default:
        title = 'test';
        break;
}

Switch run faster than if else statements because they don’t have to check all cases, just run until true and then break out

Type Coercion when data types are changed unexpectedly

Loops

Loops check a condition, if it returns true a code block will run then will check again, if still true, code block will run again, until no longer true


for (var i = 0; i < 10; i++) {
    document.write(i);
}

The preceding loop will write 0123456789 to the page.

Loop Counter

break; Exits a loop

continue; Causes the loop to stop the current iteration and then update and check the condition again, if true runs loop again

While Loop will continue as long as the condition in the () is true


var i = 1; //set counter to 1
var msg = ' '; // message

//store 5 times table in a variable
while (i < 10) {
    msg += i + ' x 5 = ' + (i * 5) + '<br />;
    i++;
}

document.getElementByID('answer').innerHTML = msg;

Loop returns the following:


1 x 5 = 5
2 x 5 = 10
3 x 5 = 15
4 x 5 = 20
5 x 5 = 25
6 x 5 = 30
7 x 5 = 35
8 x 5 = 40
9 x 5 = 45

Do While Loop statements come before the condition so the code will run at least once


Return to reading-notes Deployed Site

Return to reading-notes Mark Down