![](https://i.imgur.com/56C2ubQ.png =200x) # Coaching - JavaScript 3 with Founders and Coders --- ## Recap --- ### Equality operators ---- We use Triple equals (`===`) or double equals (`==`) to check if two things are equivalent. ---- Triple equals checks for strict equality - whether two things are of the same type and value. Double equals checks if things are the same value. ---- ```javascript= console.log("1" === 1); // logs false console.log("1" == 1); // logs true ``` --- ### If statements ---- _If statements_ allow us to define a condition to be met. When that condition is met, the code inside the statement will run. ---- ```javascript= if (myNumber === 2){ console.log('The value is two, and the type is number'); }; ``` ---- ### Else statements ---- _Else statements_ allow us to define code to run when an if block is not executed. In other words, the code will run when the if condition is not true. ---- ```javascript= if (myNumber === 2){ console.log('The value is two, and the type is number'); } else { console.log('Either the value is not two or the type is not number') } ``` ---- ```javascript= if (myNumber === 2){ console.log('The value is two, and the type is number'); } else if (myNumber == 2) { console.log("The value is two, but it is not of type: number") } else { console.log('Either the value is not two or the type is not number') } ``` --- ## For loops ---- For loops will run until a condition is met, usually we set up the condition so the loop runs a fixed number of times. ---- ```javascript= let myArray = [1,2,3,4]; for (let i = 0; i < myArray.length; i++){ myArray[i]++; }; console.log(myArray) // What does i++ do? // What is the output of line 7? ``` --- ### While loops ---- While loops allow us to run a block of code until a condition is met. ---- ```javascript= let myNum = 0; while (myNum < 10){ console.log(myNum); myNum++ } ``` ---- While loops depend on us ensuring the condition is negated somewhere in our code, otherwise the loop will run forever. ---- ```javascript= let myNum = 0; while (myNum < 10){ console.log(myNum); } // This loop will run infinitely. ``` --- ## [Practice](https://hackmd.io/@ls-ZCWdpSBmUyPFcdzy4rQ/HJmf8jOHN) 8 - 11
{"metaMigratedAt":"2023-06-16T04:49:57.437Z","metaMigratedFrom":"YAML","title":"Coaching - JavaScript 3","breaks":true,"slideOptions":"{\"theme\":\"white\"}","contributors":"[{\"id\":\"2967aacf-1990-431e-b963-91e79ce4a2bf\",\"add\":4062,\"del\":1708}]"}
    219 views
   Owned this note