wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Trial Test

Total questions: 31

Worksheet time: 18mins

Name
Class
Date
1.

Select the correct program to output "Hello" to the console.

a)

console.log("Hello");

b)

consolelog("Hello")

c)

log.console("Hello");

d)

console.logHello;

2.

Output "Hello" to the console.

(a)  

3.

Change "Leave this text." to a comment.
*Execute the program and it will output "Make the first line a comment.

a)

Leave this text.

console.log("Make the first line a comment.");

b)

//Leave this text.

console.log("Make the first line a comment.");

c)

Leave this text.

//console.log("Make the first line a comment.");

d)

//Leave this text.

log.console("Make the first line a comment.");

4.

Select the correct program that will let the computer calculate "5+7" and output the calculation results to the console.

a)

console.log("5 + 7");

b)

console.log(5" + "7);

c)

console.log("5" + "7");

d)

console.log(5 + 7);

5.

Select the correct symbol for multiplication used in the program.

a)

-

b)

/

c)

*

d)

+

6.

Let the computer calculate "3*5" and output "The answer is 15." to the console.

(a)  

7.

Select the correct declaration for the variable number.

a)

number let;

b)

number;

c)

let = number;

d)

let number;

8.

Create your program as follows

(1) Declare the variable num.
(2) Assign 5 to num
(3) Output the value of num to the console

(a)  

9.

Create your program as follows

(1) Declare the variable num and assign 7.
(2) If variable num is equal to 7, output "Correct".

a)

let num = 7;

if (num == 7){console.log("Correct");}

b)

let num == 7;

if (num = 7){console.log("Correct");}

c)

num let = 7;

if (num == 7){console.log("Correct");}

d)

let num = 7;

if (num == 7){("Correct")console.log;}

10.

select the output result of the following program.

let num = 10;

console.log(num == 10);

a)

10

b)


false

c)

true

d)

100

11.

If the value of the variable score is greater than or equal to 60, "Pass", otherwise "Fail"
*Enter only the conditional expression.

let score = 70;

if(..................................){console.log("Pass");}

else{console.log("Fail");}

a)

score >= 60

b)

score == 60

c)

60 >= score

d)

score <= 60

12.

Select a program with the conditional expression "the value of the variable num is less than 20".

a)

num >= 20

b)

num <= 20

c)

num == 20

d)

num < 20

13.

Create your program as follows.

(1) Declare the variable num and assign 100 to it.
(2) If variable num is equal to 100, output "correct".
(3) If not, "miss" is output.

a)

let num = 100;

if (num == 100){console.log("correct");}

else {console.log("miss");}

b)

let num;

if (num == 100){console.log("correct");}

else {console.log("miss");}

c)

let num = 100;

if (num = 100){console.log("correct");}

else {console.log("miss");}

d)

let num = 100;

if {console.log("correct");}

(num == 100) else {console.log("miss");}

14.

select the output result of the following program.

let score = 92; if (score == 100){console.log("Perfect score");} else if (score >= 80){console.log("So close");} else if (score >= 60){console.log("Pass");}

a)

So close

b)

Perfect score

c)

Pass

d)

No output

15.

Create a program as follows.

(1) If variable num is less than or equal to 3, output "A".
(2) If not, and if num is greater than or equal to 6, output "B".
(3) If not, output "C".

let num = 4;

if (.............................){console.log("A");}

else if (..................................){console.log("B");}

{console.log("C");}

a)

let num = 4;

if (num <= 3){console.log("A");}

else if (num >= 6){console.log("B");}

else{console.log("C");}

b)

let num = 4;

if (num >= 6 ){console.log("A");}

else if (num <= 3){console.log("B");}

else{console.log("C");}

c)

let num = 4;

if (num <= 3){console.log("A");}

else if (num >= 6){console.log("C");}

else{console.log("B");}

d)

let num = 4;

if (num <= 6){console.log("A");}

else if (num >= 3){console.log("B");}

else{console.log("C");}

16.

Select the program that means "A or B"

a)

A < B

b)

A == B

c)


A || B

d)

A && B

17.

select the output result of running the program less than or equal to

let num = 9; if (num <= 3 || num >= 7) {console.log("A");} else{console.log("B");}

a)

9

b)

No output

c)

B

d)

A

18.

Select the correct program to add 1 to variable i.

a)

i+

b)


i++1

c)

i++

d)

1+1

19.

Select the correct answer for the program that repeats the specified processing 10 times.

a)

for (let i=0; i++; i<10) {
 Specified process
}

b)

for (let i=0; i<10; i++) {
 Specified process
}

c)

for { Specified process } (
 let i=0; i<10; i++
)

d)

for (i<10; let i=0; i++) {
 Specified process
}

20.

select the output result of running the program less than or equal to

for (let i = 0; i < 2; i++) { console.log("Hello"); };

a)

Hello
Hello
Hello

b)

No output

c)

Hello
Hello

d)

Hello

21.

Create your program less than or equal to

(1) Output "Good morning" 10 times to the console.
*Variable name is i and assign 0 at the beginning.
Use the increment operator.

a)

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

console.log("Good morning");

}

b)

for console.log("Good morning") (let i=0 ; i < 10 ; i++) {

;

}

c)

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

console.log("Good morning");

}

d)

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

console.log("Good morning");

}

22.

Complete your program less than or equal to
(1) If variable a is greater than or equal to 2 and b is greater than or equal to 3, output "Condition met.
*Only the conditional expression should be entered.

let a = 4;

let b = 3;

if (.......................................) {

console.log("Condition met");

}

a)

(a >= 2 && b >=3)

b)

(a >= 2 || b >=3)

c)

(a >= 2 == b >=3)

d)

(a <= 2 && b <=3)

23.

Complete your program less than or equal to

(1) Output "Hello" three times to the console.
*Variable name is i and assign 0 at the beginning.
Use the increment operator.

.................... (.................................) {

console.log("Hello");

}

a)

If (let i=0 ; i < 3 ; i++) {

console.log("Hello");

}

b)

for (i=0 ; i < 3 ; i) {

console.log("Hello");

}

c)

for (let i=0 ; i < 3 ; i++) {

console.log("Hello");

}

d)

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

console.log("Hello");

}

24.

Select the correct function to round off.

a)

round(1.8)

b)

Math.roundoff(1.8)

c)

Math.round(1.8)

d)

round.Math(1.8)

25.

Select the output result of running the following program.

console.log(Math.max(10,50,100));

a)

160

b)

100

c)

10

d)

50

26.

Select the correct program to output random numerical values.

a)

console.log(Math.max());

b)

console.log(Math.min());

c)

console.log(random());

d)

console.log(Math.random());

27.

Select the output results of the following program.

console.log(Math.floor(12.8));

a)

No output

b)

11

c)

12

d)

13

28.

Select a program that returns a random integer as follows.

(1) Use the function Math.random to return a random numerical value.
(2) Multiply the randomly returned numerical value by 10.
(3) Use the function Math.floor to return an integer.
*The program is one line.

a)

console.log(Math.random (Math.floor(() * 10));

b)

(Math.floor(Math.random() * 10));

c)

console.log(Math.floor(Math.random() * 10));

d)

console.log(Math.floor(Math.random() );

29.

Select the correct program to create a function whose function name is sum and argument name is num.

a)

(num)function sum{
  processing
}

b)

function (num) sum {
  processing
}

c)

function sum(num) {
  processing
}

d)

(num)sum function {
  processing
}

30.

Add a program that returns the value of the variable result to the described program.

function calc(num) {

 let result = num * 7;

...................................... 

}

console.log(calc(10));

a)

function result

b)

calc(10)

c)

result return ;

d)

return result;

31.

Add a program that calls the function calc.
Enter 7 as an argument.

function calc(num) {

 let result = num * 5;

 return result;

}

console.log( (a)   );