Hello everyone,
JavaScript can be a little confusing when you first start learning how to use it, one of the first things that is important to learn about is Variables. We use variables as names for different containers with different locations within a code. To begin using a variable you want to start by tying “var myText ” into your coding program, throughout this semester in MIS we used Visual Studio Code (VSC) but there are different coding programs available. When you type “var myText” you are creating a container that you can fill with anything you want. For this example, I will be assigning myText as “Good luck, everyone!” In VSC if I wanted to have my text pop on to screen, I create it as an alert. It this will look something like this,
>script>
var myText = “Good luck, everyone!”
alert(myText);
</script>
That means when I run the program the words “Good luck, everyone!” will pop on screen as a notification. The text can be anything you want it to be, and it can be used multiple times throughout your code. This is important to know because you do not want to continue repairing certain lines of code. One question that always comes up when talking about naming variables is, is there a specific way we must name them? The answer is yes, JavaScript is lenient about how you name your containers but there are still rules that need to be followed. Variables must never start with a number, they can start with different symbols like underscores, or dollar signs, as well as uppercase and lowercase letters. You must also remember that you cannot have any spaces between names of variables. These are just some of the rules you must follow when naming variables.
Hi Sheree! I definitely agree that Javascript is a bit complicated at first. When learning variables it was hard to grasp at first sight but after practicing and reading a little more about it, it’s not as intimidating. This reminds me of our in-class activity, which I also think was helpful in fully understanding the use of variables and how to correctly input them into Javascript. Do you think that variables were an easier concept to learn versus loops, strings, etc? I think that since variables is such a concept that really ground breaks the rest of the factors to learn, I think variables were great to learn first and truly understand them.