Javascript is one of the 3 languages all web developers must learn: 1.HTML to define the content of web pages 2. CSS to specify the layout of web pages 3. JavaScript to program the behavior of web pages JS can change content .innerHTML = "
Hi there
" ////// https://www.w3schools.com/js/js_conventions.asp camelCase for defining variable & functions is recommended don't start with numbers in variable & function names! math operators: + - * / GLUE:) concatenate data parts with + if you have text(String) pieces or text and number pieces combined let mySentence = 5000 + " cars are on the highway."; console.log(mySentence) // will output: 5000 cars are on the highway. let x = 5; let y = 15; let result = x + 5 * (y / x); console.log("My result is: " + result); IN THE BROWSER CONOLE: Shift + Enter gives you multiple lines to add code. /* Timer functions / methods */ // this function only fires once after a delay of 3000 milliseconds setTimeout(function () { // do stuff alert() }, 3000); // a delay of 3 seconds // this will log the text every 5000 milliseconds setInterval(function () { console.log("5 seconds have just passed :)"); }, 5000); // function makeCake(name) { // // do stuff // } // makeCake("Peter", "40"); /* Conditionals */ // if else etc... // example with Boolean data type (true or false) let A = true; // = defines if (A == true) { // == makes a comparison alert("A is true"); } else { alert("A is false"); } //Comparison operators == means equals != means not equals // example if(A != true) > means greater than // example if(B > 0) {alert("success");} < means smaller then // example if(B < 0) {alert("error");} >= means greater than and equal to <= means smaller than and equal to {/* example if(B >= 0) {alert("success");} */ } {/* Chained-up conditionals */ } if (A == true) { alert("success!"); } else if (A == false) { alert("nope."); } else { alert("ERROR..."); } {/* Short Version */ } if (A == B) alert("YAY"); {/* Boolean specific (true|false) */ } if (A) alert("YAY"); {/* means if (A == true) ... */ } if (!A) alert("NAY"); {/* means if not (A != true)... */ } {/* Short hand */ } {/* V1 = looks to see if A is true */ } (A == true) ? alert("YAY") : alert("NAY"); {/* v2 */ } (A) ? alert("YAY") : alert("NAY"); {/* Stricter comparison operators */ } === means = is equal to and of the same data type !== means is NOT equal to and of the same data type {/* Logical operators */ } && means AND || mean OR