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);
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
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//let and var are both editable variables and can be changed later on in your program;
2let dog = 'Woof';
3//dog is equal to the string 'Woof';
4dog = false;
5//You can changed the value of dog now because it was defined with let and not const;
6
7let cow = 'Moo';
8//cow is equal to the string 'Moo';
9cow = true;
10//You can change the value of cow later on because it is not defined with const;
11
12//const is used when declaring a variable that can't be changed later on -- const stands for constant;
13const pig = 'oink';
14//This assigns the string 'oink' to pig which can not be changed because it is defined with const;
15pig = 'snort';
16//Above throws an error
17//Good Job you now know how to declare variables using JavaScript!!!
1// you an pass in strings or a number
2
3var exampleVariable = 'Example string' // this is a normal string
4var anotherExample = 839;