WorksheetsDəyişən tipləri
Total questions: 10
Worksheet time: 2hrs 40mins
In JavaScript, which data type is most appropriate for storing a logical value that can only be true or false?
string — stores text values
null — represents an empty value
number — stores numeric values
boolean — stores true/false values
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?
About 1.00 with integer division
Exactly 1.0044910179640718
Approximately 1.00449 repeating
1.00449 rounded to five decimals
Which JavaScript operator returns the remainder of a division?
Division operator (/)
Modulus operator (%)
Exponentiation operator (**)
Multiplication operator (*)
In JavaScript, which expression evaluates to true when comparing value and type strictly?
true === 1 evaluates to true
"5" === 5 evaluates to true
42 == "42" evaluates to true
42 === "42" evaluates to true
In JavaScript, what is the final output of this code shown in the image: let num = 2013; num++; num++; num--; console.log(num);
2012 after one decrement
2013 after net zero change
2014 after two increments minus one
2015 after three total increments
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?
537824 and remainder 0
537824 and remainder 1
537824 and remainder 2
537824 and remainder 3
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?
NaN then Infinity, due to invalid multiplication and division by zero
Infinity then NaN, because text coerces to number and zero is finite
NaN then 0, because division by zero returns zero in JavaScript
Infinity then 0, since multiplication with strings returns infinity
You need to store the text Did somebody say "Yoga"? in a JavaScript string. Which declaration correctly avoids breaking the string with internal quotes?
const msg = 'Did somebody say 'Yoga'?';
const msg = 'Did somebody say "Yoga"?';
const msg = "Did somebody say "Yoga"?";
const msg = "Did somebody say 'Yoga'?";
In JavaScript, which snippet correctly logs a string with an apostrophe using single quotes, without causing a syntax error?
const s = 'He's here'; console.log(s);
const s = 'He\'s here'; console.log(s);
const s = 'He"s here'; console.log(s);
const s = 'He/s here'; console.log(s);
Which JavaScript string correctly uses backticks and placeholders to greet a user by combining firstName and lastName and also includes a computed year value?
`Hello, firstName {lastName} in ${year}`
'Hello, firstName {lastName} in ${year}'
`Hello, {firstName} {lastName} in {year}`
`Hello, firstName lastName in $year`
