Search Header Logo

JavaScript Basics

Authored by amit Xalxo

Computers

KG

Used 14+ times

JavaScript Basics
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

22 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

What keyword is used to declare a variable in JavaScript?

var

function

let

const

Answer explanation

The keyword 'let' is used to declare a variable in JavaScript.

2.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

Which loop is used to iterate over an array in JavaScript?

while

switch

if

for

Answer explanation

The correct loop used to iterate over an array in JavaScript is the 'for' loop.

3.

MULTIPLE SELECT QUESTION

10 sec • 1 pt

What symbol is used for strict equality comparison in JavaScript?

===

=/=

!==

===

Answer explanation

The symbol used for strict equality comparison in JavaScript is '===' which checks both value and type.

4.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

How do you write an 'if' statement in JavaScript?

if (condition) // code block

if [condition] { // code block }

if (condition) { // code block }

if (condition) { /* code block */ }

Answer explanation

In JavaScript, the correct way to write an 'if' statement is: if (condition) { // code block }

5.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

What is the result of 10 + '5' in JavaScript?

501

105

50

15

Answer explanation

In JavaScript, when adding a number to a string, the number is converted to a string and concatenated. Therefore, 10 + '5' results in '105'.

6.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

What is the purpose of the 'for' loop in JavaScript?

To iterate over a block of code multiple times

To change the font color of a webpage

To calculate complex mathematical equations

To play music in the background

Answer explanation

The 'for' loop in JavaScript is used to iterate over a block of code multiple times, making it the correct choice.

7.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

What is the syntax for the 'switch' statement in JavaScript?

switch(expression) { case value1: // code block break; case value2: // code block break; ... default: // code block }

switch(expression) { case value1: // code block break; case value2: // code block break; ... default: // code block}

switch(expression) { case value1: // code block break; case value2: // code block break; ... default: // code block

switch{expression} case value1: // code block break; case value2: // code block break; ... default: // code block

Answer explanation

The correct syntax for the 'switch' statement in JavaScript is: switch(expression) { case value1: // code block break; case value2: // code block break; ... default: // code block}

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?