A variable in JavaScript is simply a name of storage location to hold values. A variable can be a string of characters, a string of numbers, just numbers, or a mix of both. To create a variable, you must put “var” in front of the variable name with valid variable syntax. An initialized variable is created with a value while declared variables are just created with no assigned value. Variables can contain letters, digits, underscores, and dollar signs, but they must start with a letter, dollar sign, or an underscore. Variables are case sensitive. You can refer to variables in a separate string, but they do not do into the string quotations; instead, they are separated by a “+” in between string text.
JavaScript can do a variety of mathematical operations: addition, subtraction, division, modulus. You can compute addition and subtraction using “+” and “-“, and you can compute multiplication and division using “*” and “/”. Modulus is computed by dividing the first number by the second number and then saving the remainder; it’s computed using “%”.
I think learning JavaScript has been very interesting because it’s cool to see how easy it is to code simple commands, and the results are immediate. Seeing the backend of how my favorite websites work unlocks a lot of the mystery behind the web and different websites, and can also be useful if I want to create my own website one day.
I remembered seeing var when completing the JavaScript Assignment and had to go back to it to see what we used it for. It is the same as let but just an old version. Keep in mind in class Professor Sclarlow explained we will be using let. Just mentioned for when he gives us an exam you pick the one, he wants us to use.