Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

1B Tynker JavaScript

Total questions: 23

Worksheet time: 13mins

Name
Class
Date
1.

An identifier cannot begin with a number. Which of the following is NOT a valid identifier?

a)

_identifier

b)

$IDENTIFIER

c)

1identifier

d)

Identifier1

2.

How would you call a function called “myFunction”?

a)

myfunction();

b)

myFunction();

c)

Call myFunction();

d)

call function myFunction();

3.

Identifiers in JavaScript are case-sensitive.

a)

True

b)

False

4.

You are not able to call the same function twice in a row.

a)

True

b)

False

5.

Which of the following is a correct multi-line comment?

a)

*/ hello

World */

b)

*/ hello

World /*

c)

/*hello

World /*

d)

/* hello

World */

6.

In JavaScript, an identifier may begin with an underscore, a letter, or a dollar sign. Which of the following is a valid identifier? Select all that apply.

a)

IDENT20

b)

_ident

c)

$ident1

d)

20IDENT

7.

Commented lines affect the execution of your program.

a)

True

b)

False

8.

An identifier can begin with a number.

a)

True

b)

False

9.

78090 is a valid identifier in JavaScript.

a)

True

b)

False

10.

Both of the following are valid ways to comment code:


//hello

//world


/*hello

world*/

a)

True

b)

False

11.

How far will a ship move using the following code?


for (i = 1; i < 5; i++) {

forward();

}

a)

3

b)

6

c)

4

d)

5

12.

Which is the correct syntax to make a "for" loop run for all numbers from 0 to 10?

a)

for(i = 0; i <= 10; i++)

b)

for(i = 10; i = 0; i--)

c)

for(i = 1; i < 10; i++)

d)

for(i = 0; i < 10; i++)

13.

The following code will print "hello" 25 times.

for (i = 0; i < 5; i++) {

for(i = 0; i < 5; i++) {

print("hello");

}

}

a)

True

b)

False

14.

The following "for" loop has correct syntax.

for (i = 0, i = 5, i++)

a)

True

b)

False

15.

How many times will the following "for" loop execute?

for (i = 10; i > 5; i++)

a)

20

b)

5

c)

Infinite

d)

10

16.

Choose the following "for" loops that does. not repeat 5 times.

a)

for (i = 5; i < 10; i++)

b)

for(i = 0; i <= 5; i++)

c)

for(i = 0; i < 5; i++)

d)

for(i = 1; i < 10; i = i + 2)

17.

"For" loops can increment upwards or downwards.

a)

True

b)

False

18.

Which "for" loop will move a ship 5 times?

a)

for(i = 0; i < 5; i++) {

forward();

}

b)

for(i = 0; i < 6; i++) {

forward();

}

c)

for(i = 1; i < 3; i++) {

forward();

}

d)

for(i = 1; i <5; i++) {

forward();

}

19.

Which of the following produce errors in JavaScript?

a)

Commenting incorrectly

b)

Naming variables and functions without the camelCase naming convention

c)

Indenting incorrectly

d)

All of the above

20.

What will the following "for" loop print?

for(i = 0; i < 2; i++) {

print('a');

a)

aaaa

b)

aa

c)

aaa

d)

a

21.

Which part of a conditional goes in the parentheses?

a)

The word “if”

b)

The word “else”

c)

The code to run

d)

The condition

22.

There is no difference between an "if" statement and an "if-else" statement.

a)

True

b)

False

23.

If you wanted to run different code given different conditions, how would you do that?

a)

Combine all the conditions in one condition using “or”

b)

Use “else if” statements

c)

Put everything in the “else” statement

d)

Create two functions