Are you ready?
8 questions to solve
Instructions
- This quiz goes to full-screen once you press the Start button.
- At the end of the quiz, you are able to review all the questions that you answered wrong and see their explanations.
How to declare a variable in JavaScript?
The
var
keyword is used to declare variables in JavaScript. Hence, the correct choice is (C). For more details, refer to JavaScript Basics — Variables.What does the following code log?
var x = 10;
console.log(x + 10);
In this code,
x
holds the number 10
, hence x + 10
literally translates to 10 + 10
which gives 20
. The correct choice is therefore (A). For more details, refer to JavaScript Basics — Variables.Which of the following definitions best describes a string?
A string is a sequence of textual characters. This goes with choice (D). For more details, refer to JavaScript Basics — Strings.
Which of the following values denotes a string?
In JavaScript, a string could be denoted using single quotes (
''
) or double quotes (""
). Hence, both 'Hello'
and "Hello"
are strings. The correct choice is therefore (C). For more details, refer to JavaScript Basics — Strings.What does the following code log?
var x = 10;
console.log('x');
console.log('x')
logs the string 'x'
to the console, which simply displays the character 'x'. This goes with the choice (A). For more details, refer to JavaScript Console.Which of the following denotes the three functions in JavaScript that display dialog boxes?
The functions
alert()
, confirm()
and prompt()
display dialog boxes. Hence, the correct choice is (A). For more details, refer to JavaScript Basics — Dialog boxes.What does the second argument of
prompt()
do?The second argument of
prompt()
specifies the starting value of the input field of the prompt. Hence, the correct choice is (D). For more details, refer to JavaScript Basics — Dialog boxes.What does
Number('10')
return?Passing a string to the
Number()
function returns back the equivalent number. In this case, we get back the number 10
. Hence, the correct choice is (B). For more details, refer to JavaScript Basics — Conversion to number.