Title:
JavaScript Variables and Data Types
Updated:
October 16, 2023
Task/Activity:
- Questions
- Coding Problems
Find a reference that lists all the keywords in the JavaScript programming language.
True or false: keywords are NOT case sensitive.
False
There are some rules for how you can name variables in JavaScript. What are they?
Do not start with a number, always start lowercase, no spaces, all words following the first must be capitalized (camelCase)
What is 'camelCase'?
What are ALL the different data types in JavaScript (note that there are some that we did not discuss in class)?
There are Strings, numbers, bigInts, booleans, undefined, null, symbol, and object.
What is the assignment operator and why do they call it 'assignment'?
The assignment operator is how you define variables, and they are called as such because you 'assign' the variable a value.
What is a boolean data type?
Just a true or false value.
What happens if you forget to put quotes around a string when you initialize a variable to a string?
How does JavaScript try to interperet this?
For example: var lastName = Jones;
The code assumes you are referencing another variable and bugs out.
What character is used to end a statement in JavaScript?
Semicolon(;)
If you declare a variable, but do not initialize it, what value will that variable store?
undefined
Coding Problems - See the 'script' tag below this section. You will have to write some JavaScript code in it.
Here are some tips to help you with the coding problems:
- To do this assignment, you'll need to know how to open the brower's developer tools (press F12) and look at the console log.
- Pay extremely close attention to syntax! One little syntax error can mess up your entire program.
- After you complete each problem, refresh the page in the browser and look in the console your log message and for errors.
- If you have an error in the console, check the line number of the error then look for syntax errors on that line (and the line before and the line after that line).
-
If you get stuck on this assignment, then ask for help.
Dealing with syntax errors can be extremely frustrating for beginners. It takes a lot
of help to start to get comfortable with the syntax of a language. Don't be afraid to ask for help, your success
in this class will depend on your willingnes to ask for help!