JavaScript Variables and Data Types Worksheet

Question 1

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

"Reserved" Words Here
Question 2

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

False. Keywords and variables are case sensitive
Question 3

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

  1. Variable must start with a letter
  2. the Variable will break apart upon using a space character (no spaces!)
  3. camelCasing is a good convention to follow in the field of programming
Question 4

What is 'camelCase'?

If i named a variable 'Kind of pizza customer chose', the camel casing would look something like this:
kindOfPizzaCustomerWants
Question 5

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

String (text), number, boolean -- as well as Bigint(), Undefined, Null, Symbol and Object
Question 6

What is a boolean data type?

A boolean datatype is a binary true and false datapoint. Activation of one of the two could lead someone down an entirely different path of code.
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 read that the 'lastName' variable is calling upon another variable 'Jones' for its value.
Question 8

What character is used to end a statement in JavaScript?

The semi-colon (;).
Question 9

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

The variable will store a value of 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);
The console log would read "9888"; and the following line would read 'string'.
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 console log would read: total
                                          99
Question 12

What is the difference between these two variables?


const score1 = 75;
const score2 = "75";
One is a variable with the data of a number,
the other variable has data as a string.
Question 13

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


const score = 0;
score = prompt("Enter a score");
the variable "score" has been assigned an unchanging const behavior.
The console log will report an error reflecting this mistake.

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: