The course is part of this learning path
- Learn what variables are and how to create them
- Learn about a range of primitive data types
This course is targeted towards absolute beginners.
Now, what if I wanted to display the value of the my name variable? Due to the nature of this environment, we do have the browser console to the right, and this gives us access to the built-in function console.log that I will demonstrate. So on the line below, I will type consult.log with parentheses and inside of the parentheses, I have to pass through our argument, which is in this case, my name, the variable. So I will type in my name, now I will hit run and on the right, we can see my name being displayed in the console.
Now console log is primarily used as a messaging system for debugging, but in this environment, we're gonna use it to display values. Now, hypothetically, what if later on in the program you wanna change the value of the my name variable? Well, that is called variable reassignment, and to demonstrate this on the line below, I will type my name and then equal sign, and now I will give it a value of Lori, which is a string, so I'll wrap it in quotes.
Note that I did not use the keyword var when reassigning the value of the my name variable. If I were to use var, I would be re-declaring the variable, creating a new instance of this variable overriding the previous one in the memory. Now I'm gonna hit run again to display the current value of my name in the console and to the right we can see it's now Lori, the next primitive data type I will discuss is a number which is used for numeric data.
So on the next line below, I'm gonna declare a number, so I'm gonna make a variable called var number equal 20 semi-colon. If I were to wrap the number in quotes, it would be treated as a string, not as a number.
Now the next primitive I will discuss is boolean, which is a binary data type with only two possible values, true or false. In on the next line, I'm gonna write out an example, var invoice paid equals true. I'm gonna discuss a hypothetical situation where a variable like this may be used, invoicing software.
Typically in most invoicing software, there's a status of whether an invoice has been paid or not. When the invoice is generated, the default paid status is usually set to false, and then when it's paid that status is changed from false to true, and this is one of many potential scenarios where a boolean value would be used.
Farish has worked in the EdTech industry for over six years. He is passionate about teaching valuable coding skills to help individuals and enterprises succeed.
Previously, Farish worked at 2U Inc in two concurrent roles. Farish worked as an adjunct instructor for 2U’s full-stack boot camps at UCLA and UCR. Farish also worked as a curriculum engineer for multiple full-stack boot camp programs. As a curriculum engineer, Farish’s role was to create activities, projects, and lesson plans taught in the boot camps used by over 50 University partners. Along with these duties, Farish also created nearly 80 videos for the full-stack blended online program.
Before 2U, Farish worked at Codecademy for over four years, both as a content creator and part of the curriculum experience team.
Farish is an avid powerlifter, sushi lover, and occasional Funko collector.