reading-notes

Reading Notes

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

Code 102: Class 08 - Operators and Loops


Read: JavaScript and JQuery Text pg 150 - 151

Comparison operators can compare one value in the script to its expected value and result boolean

Read: JavaScript and JQuery Text pg 156 - 157

Logical Operators

Short Circuit Evaluation logical evaluations evaluate from left to right and will stop as soon as they are satisfied of the result

Read: JavaScript and JQuery Text pg 156 - 157

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

Read: JavaScript and JQuery Text pg 176

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


Return to reading-notes Deployed Site

Return to reading-notes Mark Down