Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Dəyişən tipləri

Total questions: 10

Worksheet time: 2hrs 40mins

Name
Class
Date
1.

In JavaScript, which data type is most appropriate for storing a logical value that can only be true or false?

a)

string — stores text values

b)

null — represents an empty value

c)

number — stores numeric values

d)

boolean — stores true/false values

2.

Given the code snippet shown in the image: const first = 2013; const second = 2004; console.log(first + second); console.log(first - second); console.log(first * second); console.log(first / second); which console output is correct for the division operation?

a)

About 1.00 with integer division

b)

Exactly 1.0044910179640718

c)

Approximately 1.00449 repeating

d)

1.00449 rounded to five decimals

3.

Which JavaScript operator returns the remainder of a division?

a)

Division operator (/)

b)

Modulus operator (%)

c)

Exponentiation operator (**)

d)

Multiplication operator (*)

4.

In JavaScript, which expression evaluates to true when comparing value and type strictly?

a)

true === 1 evaluates to true

b)

"5" === 5 evaluates to true

c)

42 == "42" evaluates to true

d)

42 === "42" evaluates to true

5.

In JavaScript, what is the final output of this code shown in the image: let num = 2013; num++; num++; num--; console.log(num);

a)

2012 after one decrement

b)

2013 after net zero change

c)

2014 after two increments minus one

d)

2015 after three total increments

6.

A two-digit integer num is stored. Write the console output that a program should produce if it first computes num raised to the 5th power and then prints the remainder when num is divided by 3 for num = 14. What two values should be printed, in order, separated by a space?

a)

537824 and remainder 0

b)

537824 and remainder 1

c)

537824 and remainder 2

d)

537824 and remainder 3

7.

Consider the code snippet shown in the image: console.log('Text' * 5); console.log(256 / 0); What are the respective outputs of these two statements, and why?

a)

NaN then Infinity, due to invalid multiplication and division by zero

b)

Infinity then NaN, because text coerces to number and zero is finite

c)

NaN then 0, because division by zero returns zero in JavaScript

d)

Infinity then 0, since multiplication with strings returns infinity

8.

You need to store the text Did somebody say "Yoga"? in a JavaScript string. Which declaration correctly avoids breaking the string with internal quotes?

a)

const msg = 'Did somebody say 'Yoga'?';

b)

const msg = 'Did somebody say "Yoga"?';

c)

const msg = "Did somebody say "Yoga"?";

d)

const msg = "Did somebody say 'Yoga'?";

9.

In JavaScript, which snippet correctly logs a string with an apostrophe using single quotes, without causing a syntax error?

a)

const s = 'He's here'; console.log(s);

b)

const s = 'He\'s here'; console.log(s);

c)

const s = 'He"s here'; console.log(s);

d)

const s = 'He/s here'; console.log(s);

10.

Which JavaScript string correctly uses backticks and placeholders to greet a user by combining firstName and lastName and also includes a computed year value?

a)

`Hello, firstName{firstName} {lastName} in ${year}`

b)

'Hello, firstName{firstName} {lastName} in ${year}'

c)

`Hello, {firstName} {lastName} in {year}`

d)

`Hello, firstNamefirstName lastName in $year`