JavaScript Variables and Data Types Worksheet

Question 1

Find a reference that lists all the keywords in the JavaScript programming language.

JavaScript Keywords Reference
Question 2

True or false: keywords and variable names are NOT case sensitive.

false
Question 3

There are some rules for how you can name variables in JavaScript. What are they?

You can't use number at the start when naming variables and you need to use camel casing.
Question 4

What is 'camelCase'?

Camel casing is when you name a variable with two words or more but the starting letter of the first word is in lower case and the next starting letting of the next word is in uppercase and so on. There are no spaces so we use uppercasing to declare the next word.
Question 5

What are ALL the different data types in JavaScript (note that there are some that we did not discuss in class)?

All data types are Strings,boolean, numbers, undefines, null, symbol, biglnt, object, arrays, function, and data.
Question 6

What is a boolean data type?

A boolean data type is a true or false statement.
Question 7

What happens if you forget to put quotes around a string when you initialize a variable to a string value? How does JavaScript try to interpret this?
For example: var lastName = Jones;

If you forget to put quotes around a string it treated as a variable instead of a text.
Question 8

What character is used to end a statement in JavaScript?

You need to use a semicolon at the end.
Question 9

If you declare a variable, but do not initialize it, what value will the variable store?

The variable will be store the value as undefined.
Question 10

What output will the following program produce? In other words, explain what you would see in the console log if you ran a program like this:


const firstTestScore = 98;
const secondTestScore = "88";
const sum = firstTestScore + secondTestScore;
console.log(sum);
console.log(typeof sum);
You would see the output as 186 because you're adding the firstTestScore and the secondTestSCore. The last line of code tells us what kind of data type it is.
Question 11

What output will the following program produce? In other words, explain what you would see in the console log if you ran a program like this:


const total = 99;
console.log("total");
console.log(total);
It would print out the word total and then the total number under that.
Question 12

What is the difference between these two variables?


const score1 = 75;
const score2 = "75";
The first line is a number variable and the second line is a string variable.
Question 13

Explain why the this code will cause the program to crash:


const score = 0;
score = prompt("Enter a score");
We declared the variable score as an const instead of let.

Coding Problems

Coding Problems - See the 'script' element below this h1 element. You will have to write some JavaScript code in it.

Here are some tips to help you with the coding problems: