wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JavaScript Input and Variables Quiz

Total questions: 20

Worksheet time: 58mins

Name
Class
Date
1.

What is the proper function to call to print to the screen?

a)

write

b)

println

c)

PRINT

d)

post

2.

How will the output look in the following programs?

a)

The code snippet will print Hello World on a single line.

b)

The code snippet will print Hello on the first line and World on the second line.

c)

The code snippet will print an error because of the extra space after the letter o.

d)

The code snippet requires only one println.

3.

What keyword do you need to use to define a variable in JavaScript?

a)

println

b)

var

c)

float

d)

int

4.

A naming convention where the first letter is lower case, and each subsequent start of a word is upper case

a)

capitalization

b)

variable

c)

upperCase

d)

lowerCamelCase

5.

What is the output to the console to the following JavaScript program?

a)

1

2

3

b)

1

2

.3

c)

1

2

.03

d)

1

2

0.03

6.

What are the different variable types that can be used in Javascript?

a)

Booleans, Numbers, Strings

b)

Booleans, Int, Float

c)

Strings, Booleans, Int

d)

Strings, Int, Doubles

7.

How would you create a variable named myPet and give it the value “Your Name”?

(a)  

8.

How would you create a variable named digNum and give it the value 33?

(a)  

9.

How would you print out the value stored inside of a variable named totAmount?

(a)  

10.

What variable type will you use for the number 56.43?

a)

String

b)

Int

c)

Float

d)

Boolean

11.

What variable type will you use for true or false statement?

a)

String

b)

Int

c)

Float

d)

Boolean

12.

What function do you need to call to ask the user of the program to enter text?

a)

readLine

b)

readln

c)

text

d)

println

13.

To ask the user of the program for the number 8, which function should you use?

a)

readLine

b)

readInt

c)

readFloat

d)

readNumber

14.

To ask the user of the program for the number 10.00, which function should you use?

a)

readLine

b)

readInt

c)

readFloat

d)

readNumber

15.

What are the JavaScript functions we can use to get input from the user?

a)

readLine(), readFloat(), readInt()

b)

readLine, readFloat, readInt

c)

readLine<>, readFloat<>, readInt<>

d)

readLine{}, readFloat{}, readInt{}

16.

Which program snippet will read the age from the user?

a)

var age = readInt("What is your age:");

println(age);

b)

var age = readLine("What is your age:");

println(age);

c)

var age = readFloat("What is your age:");

println(age);

d)

var age = readNum("What is your age:");

print(age);

17.

How will the output look in the following programs?

a)

Hello bulldog, nice to meet you!

b)

Hello Alexander, nice to meet you!

c)

Hello name, nice to meet you!

d)

Syntax Error

18.

What is the output to console for the following JavaScript program?

a)

Our Sales Tax is 8%

b)

Our Sales Tax is .08%

c)

Our Sales Tax is%

d)

Syntax Error

19.

What is the output to the console in the following JavaScript program?

a)

123

b)

1

2

3

c)

12

3

d)

1

23

20.

What is the output to the console to the following JavaScript program?

a)

7

8

.09

b)

7

8

0.09

c)

num1 num2 num3

d)

15.09