reading-notes

Class 8: Operators and Loops

Resources

Some Notes

Assignment Operators

Comparison Operators

For Statements

While Statements

Example: let n = 0; let x = 0; while (n < 3) { n++; x += n; }

Practice

function favColor(){ let userGuess = prompt(“What is my favorite color?”); if (userGuess == “yellow”){ console.log(“That is correct”); } else { console.log(“That is wrong”); favColor(); } } // This function will continue to loop until the correct answer is given.

Things I Would Like to Know

I would like to get to a point skillwise where I can tell when it’s most efficient to loop with a function, or with an actual loop (whether the loop is a for loop or a while loop).