JavaScript Variables and Data Types Worksheet

Question 1

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

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?

Case-sensitive, can contain letters, digits, underscores, cannot use reseved key words like, let, const, and function.
Question 4

What is 'camelCase'?

A program where the first word is lower case and after that word is capiatlized. Ex: firstName.
Question 5

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

String, Boolean, Null, Number, BigInt, Undefined, Symbol.
Question 6

What is a boolean data type?

True or Flase values.
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;

JavaScript will try to interpret it as a variable name instead of a string.
Question 8

What character is used to end a statement in JavaScript?

The semicolon.
Question 9

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

JavaScript assigns it the value undefined by default.
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);
In the first console.log you will have the sum of the first test score and the second test score. In the second console.log you will find the the answer to the string function.
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);
The first console.log will show the string "total" The second console.log will show you the value of the variable total which would be 99.
Question 12

What is the difference between these two variables?


const score1 = 75;
const score2 = "75";
score1 is a number and score2 is a string because there are quotation marks.
Question 13

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


const score = 0;
score = prompt("Enter a score");
The code is trying to reassign the value of the const.

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: