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 user_name = prompt("Please enter your name:", "Type here");
2alert("Hello " + user_name);
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
1//Making variables with let:
2let numberOfFriends = 1;
3
4//Incrementing:
5numberOfFriends += 3; //numberOfFriends is now 4
6
7// Variables with const
8const minimumAge = 21; //CANNOT REASSIGN!
9
10//Booleans - true or false values
11true;
12false;
13let isHappy = true;
14
15//Naming Conventions
16// Use upper camel-cased names:
17let numberOfChickens = 6; //GOOD
18// NOT THE JS WAY:
19// let number_of_chickens = 6;
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};
1var a; // variable
2var b = "init"; // string
3var c = "Hi" + " " + "Joe"; // = "Hi Joe"
4var d = 1 + 2 + "3"; // = "33"
5var e = [2,3,5,8]; // array
6var f = false; // boolean
7var g = /()/; // RegEx
8var h = function(){}; // function object
9const PI = 3.14; // constant
10var a = 1, b = 2, c = a + b; // one line
11let z = 'zzz'; // block scope local variable
12