Why do programmers use variables?
JavaScript Quiz

Quiz
•
Computers
•
9th - 10th Grade
•
Hard
Jeffery Vann
Used 38+ times
FREE Resource
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Because they are lazy and don’t want to write out equations every time
It allows the programmer to reuse multiple lines of code
They are a way to document functions
To store values to easily reuse later and make code easier to read and understand
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
If you were given the following variables:
var distance = 2;
var time = 30;
What line of code would print the speed in km/hr if the distance is given in km and the time is given in minutes? (Speed = distance/time)
println(distance/(time/60));
println(distance/time);
println(distance*(time*60));
println(distance*time);
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is printed to the screen if the user enters ‘5’ when the following program is run?
var userNum = readInt("Enter your favorite number: ");
var calculatedNum = (userNum * userNum) + userNum;
println(calculatedNum);
5
30
25
50
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
A store has 20 apples in its inventory. How can you store this information in a JavaScript variable?
var numApples == 20;
20 = numApples;
var numApples = 20;
var num apples = 20;
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
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?
var applesToBuy = readLine("How many apples would you like? ");
var applesToBuy = println("How many apples would you like? ");
var applesToBuy = readInt("How many apples would you like? ");
var applesToBuy = nextInt("How many apples would you like? ");
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
You are splitting up all of your apples equally between 3 people. Which statement below will calculate how many apples will be left over?
var leftOver = numApples / 3;
var leftOver = numApples % 3;
var leftOver = 3 / numApples;
var leftOver = 3 % numApples;
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In order to write the function rollDice() for a game, I need to generate and store a random integer between 1 and 6. Which statement below will accomplish this task?
var diceRoll = Randomizer.nextInt(1,6);
var diceRoll = Randomizer.nextInt(0,7);
var diceRoll = Randomizer.nextNum(1,6);
var diceRoll = Randomizer(1,6);
Create a free account and access millions of resources
Similar Resources on Quizizz
15 questions
Array

Quiz
•
10th - 12th Grade
16 questions
Basic C# Programming Quiz

Quiz
•
9th Grade
15 questions
Basics in Java

Quiz
•
9th - 12th Grade
15 questions
JavaScript Knowledge & Skills

Quiz
•
9th - 12th Grade
20 questions
Arrays in Java

Quiz
•
9th - 12th Grade
16 questions
Arithmetic Types Declare Initialize Relation Logical Ops

Quiz
•
9th Grade - University
17 questions
"switch" Java Statement - 1

Quiz
•
9th - 10th Grade
19 questions
Java Base

Quiz
•
9th - 12th Grade
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade
Discover more resources for Computers
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Taxes

Quiz
•
9th - 12th Grade
17 questions
Parts of Speech

Quiz
•
7th - 12th Grade
20 questions
Chapter 3 - Making a Good Impression

Quiz
•
9th - 12th Grade
20 questions
Inequalities Graphing

Quiz
•
9th - 12th Grade
10 questions
Identifying equations

Quiz
•
KG - University