Page 2
This page is using the info on javascript.info
- The triple equals symbol: === means equals. If two numbers are equal this is the sign.
- Code between curly braces is called a block.
-
if 10 < 5 { // run some code here }
This would not run the code because 10 is not less than 5.
- Another variation of the
if
is theif / else
.if (43 < 2) { // Run the code in here } else { // Run a different bit of code }
-
Embedding variables into a a string
Usually you can only have a string of text between it's open and closing quotes. However you can add a variable if you use backticks instead of quotes
let name = "John"; // embed a variable alert( `Hello, ${name}!` );
-
Using Replace
Replace is a function can be used to replace any string or part of a string. Type this into the console.
let insult = 'u fuckin wanker'; insult.replace('wanker', 'arsehole'); // returns: u fuckin arsehole
-
You can define a variable without a value. For instance
let admin;
. What happens when you call such a variable, for instance in an alert: