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?

you have to use Camel Case when using Java, and can use the "" to name variables.
Question 4

What is 'camelCase'?

each word in a sentence has to start with a capital and they have to not be spaced.
Question 5

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

if, let, const, var,
Question 6

What is a boolean data type?

boolean is something that has to be true or false, nothing in between
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 quotes around a string it will crash your code because it will think your string is a variable.
Question 8

What character is used to end a statement in JavaScript?

;
Question 9

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

it will store the lowercase
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);
it will result in an error because you arent using the let variable. syntax error.
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);
this will show the string instead of the actual total. const total = 99; console.log(total);
Question 12

one is the string and the other the variable.


const score1 = 75;
const score2 = "75";
const score1 = 75 const score2 = 75
Question 13

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


const score = 0;
score = prompt("Enter a score");
because it sees 0 as a number.

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: