JavaScript Variables and Data Types Worksheet
Question 1Find a reference that lists all the keywords in the JavaScript programming language.
Question 2True or false: keywords and variable names are NOT case sensitive.
myVar and MyVar are different.
There are some rules for how you can name variables in JavaScript. What are they?
What is 'camelCase'?
myVariableName.
What are ALL the different data types in JavaScript?
- String
- Number
- Boolean
- Undefined
- Null
- Object
- Symbol
- BigInt
What is a boolean data type?
true or false.
It’s often used for conditional testing.
What happens if you forget to put quotes around a string when you initialize a variable to a string value?
ReferenceError.
What character is used to end a statement in JavaScript?
;) is used to end a statement.
If you declare a variable, but do not initialize it, what value will the variable store?
undefined.
What output will the following program produce?
const firstTestScore = 98;
const secondTestScore = "88";
const sum = firstTestScore + secondTestScore;
console.log(sum);
console.log(typeof sum);
9888
string
Because the number is concatenated with the string, resulting in a string.
What output will the following program produce?
const total = 99;
console.log("total");
console.log(total);
total
99
The first console.log prints the word “total”, the second prints the variable’s value.
What is the difference between these two variables?
const score1 = 75;
const score2 = "75";
score1 is a Number data type, while score2 is a String data type.
Explain why this code will cause the program to crash:
const score = 0;
score = prompt("Enter a score");
const variables cannot be reassigned.
Use let instead of const if you need to change its value.