1//choose the best for your solution
2var myVariable = 22; //this can be a string or number. var is globally defined
3
4let myVariable = 22; //this can be a string or number. let is block scoped
5
6const myVariable = 22; //this can be a string or number. const is block scoped and can't be reassigned
1var variable = 10;
2
3function start() {
4 variable = 20;
5}
6console.log(variable + 20);
7
8// Answer will be 40 since the variable was changed in the function
1var user_name = prompt("Please enter your name:", "Type here");
2alert("Hello " + user_name);
1var a;
2console.log(a); // scrive in console "undefined" o "" a seconda del browser usato.
3console.log('still going...'); // scrive in console "still going...".
1var Number = 5;
2var String = "Hi!";
3var boolen1 = true;
4var boolen2 = false;
5var array = [11, "Hi!", true];
6var object = {age:11, speach:"Hi!", likes_Bananas:true};
1// Also let, const
2var e_number = 0;
3var e_string = '';
4var e_true = true;
5var e_false = false;
6var e_undefined = undefined;