wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JavaScript Level 1

Total questions: 20

Worksheet time: 33mins

Name
Class
Date
1.

How do I generate a random number from 0 to less than 1?

a)
b)
c)
d)
2.

How do I add comments in my codes?

a)

Use double forward slash, like this:

// say something

b)

Use /* and */ to enclose some lines of text as comments

c)

Use #, hash symbol, like this:

# say something

d)

Use <!-- and --> to enclose some lines of text as comments

3.

Which of the following will ask for input when you run the program?

a)
b)
c)
d)
4.

What will be printed in the console?

a)

Error. This code cannot run.

b)

29 February

c)

11 February

d)

2+9+February

5.

Which of the following is/are valid JavaScript variable name(s)?

a)

num1

b)

1num

c)

my_name

d)

my name

6.

I want to use a String variable to store some text value in my program. Which one is correct?

a)

let some text = can i ask a question?;

b)

def some_text = "can i ask a question?";

c)

let some_text = "can i ask a question?";

d)

def some_text = can i ask a question?;

7.

I want to use a number variable to store some numerical value in my program. Which one is correct?

a)

let 1num = 100;

b)

def 1num = "100";

c)

let num1 = 100;

d)

let num1 = "100";

8.

Which function should I use to convert String value to number?

a)

int()

b)

parseInt()

c)

ParseInt()

d)

parseint()

9.

What is printed in the console when you run this program?

a)

Error. This code has syntax error.

b)

you can proceed to book for a vaccination slot now.

c)

please wait for further notification.

d)

Nothing is printed in the console.

10.

Which function do I use for a pop-up window to show some text messages?

a)

alert()

b)

print()

c)

prompt()

d)

console.log()

11.

What is printed in the console when you run this program?

a)

Error. This code has syntax error.

b)

you can proceed to book for a vaccination slot now.

c)

please wait for further notification.

d)

Nothing is printed in the console.

12.

When prompted, the input value is entered as 19.

What is the output printed in the console?

a)

Error. The code has syntax error.

b)

39

c)

1920

d)

2019

13.

Which Math operator should I use when I want to check if a number is odd or even?

a)

%

b)

+

c)

*

d)

/

14.

Which Math operator should I use when I want to check if a number is a multiple of 5?

a)

%

b)

+

c)

*

d)

/

15.

Look at the codes. Which of the following is/are correct?

a)

Numbers 0 to 8 are printed.

b)

Numbers 1 to 8 are printed.

c)

Error. This code has syntax error.

d)

This showed an example of a "for loop".

16.

Refer to this code, and what is printed in the console?

a)

Numbers from 0 to 99

b)

Numbers from 1 to 100

c)

Numbers from 0 to 100

d)

Numbers from 1 to 99

17.

Read the codes. Then what is the name of the loop used in this program?

a)

For Loop

b)

While Loop

c)

Do-while Loop

d)

Forever Loop

18.

Read the codes. Line 6: What is the purpose of using a "break" statement?

a)

To break the codes into multiple lines.

b)

To terminate the loop.

c)

This is an example of "forever" loop.

d)

To take a break from doing homework.

19.

Read the codes. What is printed in the Console? There maybe more than 1 correct answer.

a)

I got here

b)

Numbers 99 to 91 are printed in the Console.

c)

Numbers 100 to 91 are printed in the Console.

d)

Nothing is printed.

20.

Read the codes. What will be displayed in the pop-up window?

a)

what? and why?

b)

you are 5 years old

c)

you are older than 5 years old

d)

Nothing is shown