NEW
Font size
WorksheetsJavaScript Basics Quiz
Total questions: 15
Worksheet time: 8mins
What does the readLine() function do in JavaScript?
Reads a number from the user
Reads a string from the user
Displays text on the screen
Runs a loop
Which function allows reading a number with decimals?
readInt()
readFloat()
readString()
readDecimal()
Which function is used to display text in JavaScript?
print()
show()
println()
display()
What is a variable?
A fixed value
A container that holds data
A programming error
A type of function
Which line correctly declares and initializes a variable?
age = 15;
var age = 15;
variable age 15;
int age = 15;
What type of data does a Boolean variable hold?
Text
Numbers
True or False
Characters
What happens if you forget quotation marks around a string?
The program crashes
It runs normally
It prints numbers only
It becomes a Boolean
Which is the correct syntax for combining variables and text?
println("My age is", age);
println("My age is " + age);
print(age "My age is");
println("age " "My is");
What symbol is used to join text and variables in JavaScript?
*
&
+
=
What does the following code print? var color = "Blue"; println("My favorite color is " + color);
Blue
My favorite color is Blue
My favorite color is
color = Blue
What does the readInt() function do?
Reads text from the user
Reads a decimal number
Reads a whole number
Prints a number to the screen
What type of number does readFloat() return?
Integer
Decimal
String
Boolean
Which of the following correctly declares a variable in JavaScript?
let = name "John";
var name = "John";
var = name "John";
name var = "John";
What is the purpose of a variable?
To store data
To display output
To delete data
To repeat commands
Which statement is true about variables?
They can only store numbers
They cannot change once set
They can hold different types of data
They are only used in math
