Practice with
Variables
Assignment:
The purpose of this quick exercise if to let you practise using variables
in JavaScript. You will gain a better understanding of:
- Values and Literals, including:
- Arrays
- Arithmetic in JavaScript
Choose appropriate variables for the following situations, and assign them the specified values.
- There are four dice, whose values are 3, 6, 2 and 4 respectively.
- My television is turned on.
- Now, my television is turned off.
- The name of a surgeon is Robert.
- Question #13 on the test has been answered incorrectly.
- Scott owns five cars.
- Scott owns the same number of computers as cars. (Hint: use the variable
declared in the previous question.)
Declare the following variables:
- An array of size 5
- A boolean indicating false
- A floating point value
- Two strings
- A string concactenating the two strings you have just created
Make corrections to the following code:
name = Mary;
lastName = Ford;
fullName = name + lastName;
firstNumber = 1;
secondNumber = 2
sum = firstNumber + secondnumber;
true = response;
printedAnswer = "The answer is" +response ".";
new Array(5);
array[5]=4;
total = 5
total = total +"10";

HOME