Variables in JavaScript are items that we input into our code that contains some sort of data or value. We declare variables by writing “let” and then the variable that you want to make. However, variables do not just magically get values when you determine your variable. You must assign data or value to your variable. An example of creating a variable would be by writing, ‘let myName =’. And to create value, I could write ‘let myName = “madison”;’. The data is actually adding my name to the variable of myName. You can pretty much make your variable whatever you want as we have learned that JavaScript allows you freedom to create your own variables.
Here are some of the rules to consider when creating a variable. They can be short, one word, or long, endless characters or words. A good place to start when creating your variable is thinking how it starts. They cannot start with a number, so begin with a letter, underscore or a dollar sign. Another good thing to remember is that they cannot have spaces, your variable must be all one word, or multiple words put together without space. And although it can’t begin with a number, there can certainly be numbers within the variable. Finally, you can use upper and lower case letters. These are the basics to get you started.
I feel like It was very easy to understand what variables are and how they are used in script after reading this.