Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JavaScript Quizz Batch 2

Total questions: 20

Worksheet time: 28mins

Name
Class
Date
1.

What is the correct syntax to output "Hello My Name is Amy" in JavaScript?

a)

println("Hello My Name is Amy")

b)

echo("Hello My Name is Amy");

c)

console.log("Hello My Name is Amy")

d)

printf("Hello My Name is Amy")

2.

What does the typeof operator return for?

a)

Array

b)

Object

c)

String

d)

Boolean

3.

Which of these is a correct way to declare a constant in JavaScript?

a)

const PI = 3.14

b)

let PI = 3.14

c)

var PI = 3.14

d)

const PI = 3,14

4.

What will the following code output?

a)

true

b)

false

c)

undefined

d)

NaN

5.

Which one is the correct code to make the string ALL CAPS?

a)

message = message.toLowerCase()

b)

message = message.toUppercase()

c)

message = message.toupperCase()

d)

message = message.toUpperCase()

6.

Which is the following is a correct arrow function syntax?

a)

function hello ( ) => {

console.log(`Hello`)

}

b)

const hello = ( ) => {

console.log(`Hello`)

}

c)

hello ( ) => {

console.log(`Hello`)

}

d)

hello => console.log('Hello')

7.

How do you create an array in JavaScript?

a)

let arr = "1, 2, 3"

b)

let arr = "[1, 2, 3]"

c)

const arr = "[1, 2, 3]"

d)

const arr = [1, 2, 3]

8.

What is the output of console.log(typeof NaN); ?

a)

number

b)

NaN

c)

undefined

d)

object

9.

Which keyword is used to create a function in JavaScript?

a)

function

b)

Function

c)

class

d)

object

10.

How can you check if a variable x is an array?

a)

x instanceof Array

b)

x == "array"

c)

typeof x === "array"

d)

x.isArray()

11.

What is the purpose of adding async before keyword function?

a)

Enables asynchronous code

b)

Does nothing

c)

Makes the code run faster

d)

Using arrow function

12.

What will this code print?

a)

null

b)

undefined

c)

0

d)

ReferenceError

13.

Which statement is true about using the map() method in JavaScript?

a)

map() changes the original array

b)

map() does not need a return statement

c)

map() creates a new array and usually needs a return

d)

map() is used only for sorting numbers

14.

Which function is used to delay execution in JavaScript?

a)

wait()

b)

setTimeout()

c)

delay()

d)

pause()

15.

What does this function return?

a)

5

b)

undefined

c)

6

d)

NaN

16.

What does this code output of console.log("5" + 1); ?

a)

6

b)

51

c)

NaN

d)

Error

17.

Which keyword allows you to make a variable value changeable?

a)

var

b)

let

c)

const

18.

Which keyword allows you to declare a variable in JavaScript without reassigning or modifying its value afterward?

a)

let

b)

var

c)

const

d)

static

19.

What is the purpose of a try...catch block in JavaScript?

a)

To create a loop

b)

To declare variables

c)

To handle errors in the code

d)

To define functions

20.
a)

Error: y is not defined

b)

Error happened!

c)

y

d)

1