NEW
Font size
WorksheetsJavaScript Variables Quiz
Total questions: 19
Worksheet time: 10mins
What are variables in JavaScript similar to?
Puzzle pieces
Functions
Little boxes to store values
Strings
Loops
Which keyword is commonly used to declare a variable in JavaScript?
const
let
int
float
var
If you declare a variable without initializing it, what is it called?
Uninitialized
Null
Empty
Undefined
Zeroed
What does initializing a variable mean?
Naming it
Assigning a value to it
Creating a box for it
Naming and assigning a value to it
Deleting it
Which of the following is the correct way to declare and initialize a variable to store the number 10?
int number = 10;
number = 10;
var number = 10;
float number = 10;
number 10;
What is the output of the following code? `var value = 53; value = 75; console.log(value);`
53
75
5375
Error
None of the above
Which type of variable is used to hold true or false values?
String
Integer
Char
Float
Boolean
Which variable declaration contains a decimal point and can hold numbers like 2.5?
Integer
Char
String
Float
Boolean
How are strings represented in JavaScript?
like this "Alice"
Without quotes
Using special characters
Using numbers
All of the above
What type of value does the following variable hold? `var apple = "fruit";`
Integer
Float
Boolean
String
Char
What is the naming convention where each word after the first begins with a capital letter?
SnakeCase
camelCase
PascalCase
kebab-case
UPPER_CASE
Which of the following is a good variable name?
5$age
4_name
var
appleTree
2apples
What type of variable is `var loggedIn = true;`?
Integer
String
Float
Boolean
Char
What is an Integer?
A number with decimal points 小数
A sequence of characters 字符
A true or false value 布尔值
A whole number 整数
A data storage structure储存结构
What is the difference between declaring and initializing a variable?
Declaring means giving it a name and initializing means assigning it a value.
Declaring means deleting it and initializing means recreating it.
Declaring and Initializing mean the same thing.
Declaring means assigning it a value and initializing means deleting it.
None of the above
Which of these is a special keyword in JavaScript?
variable
init
string
true
function
Which of the following is NOT a valid way to declare and initialize a variable in JavaScript?
var name = "John";
int age = 25;
var loggedIn = true;
var price = 10.5;
var _privateVar = "hidden";
In the context of JavaScript, what is a Float?
A sequence of characters
A true or false value
A whole number
A numeric value with decimal precision
A data storage type
If you want a calculation result to be a decimal, what must one of your numbers be?
Integer
Char
String
Boolean
Float
