JAVASCRIPT UNIT 3 EXAM
QUESTIONS AND ANSWERS
A store has 20 apples in its inventory. How can you store this information in a
JavaScript variable?
let numApples == 20;
20 = numApples;
let numApples = 20;
let num apples = 20; - Correct Answers -let numApples = 20;
You want to read input from the user to know how many apples they would like to buy.
Which statement should you use to read in a number from the user?
let applesToBuy = readLine("How many apples would you like? ");
let applesToBuy = console.log("How many apples would you like? ");
let applesToBuy = readInt("How many apples would you like? ");
let applesToBuy = nextInt("How many apples would you like? "); - Correct Answers -let
applesToBuy = readInt("How many apples would you like? ");
You are splitting up all of your apples equally between 3 people. Which statement below
will calculate how many apples will be left over?
let leftOver = numApples / 3;
let leftOver = 3 / numApples;
let leftOver = numApples % 3;
let leftOver = 3 % numApples; - Correct Answers -let leftOver = numApples % 3;
What is the output of the following program: (Assume the user enters 'Florence' then
'Fernandez'.)
let firstName = readLine("What is your first name? ");
let lastName = readLine("What is your last name? ");
let wholeName = firstName + lastName;
console.log(wholeName);
QUESTIONS AND ANSWERS
A store has 20 apples in its inventory. How can you store this information in a
JavaScript variable?
let numApples == 20;
20 = numApples;
let numApples = 20;
let num apples = 20; - Correct Answers -let numApples = 20;
You want to read input from the user to know how many apples they would like to buy.
Which statement should you use to read in a number from the user?
let applesToBuy = readLine("How many apples would you like? ");
let applesToBuy = console.log("How many apples would you like? ");
let applesToBuy = readInt("How many apples would you like? ");
let applesToBuy = nextInt("How many apples would you like? "); - Correct Answers -let
applesToBuy = readInt("How many apples would you like? ");
You are splitting up all of your apples equally between 3 people. Which statement below
will calculate how many apples will be left over?
let leftOver = numApples / 3;
let leftOver = 3 / numApples;
let leftOver = numApples % 3;
let leftOver = 3 % numApples; - Correct Answers -let leftOver = numApples % 3;
What is the output of the following program: (Assume the user enters 'Florence' then
'Fernandez'.)
let firstName = readLine("What is your first name? ");
let lastName = readLine("What is your last name? ");
let wholeName = firstName + lastName;
console.log(wholeName);