WorksheetsJavaScript Quizz Batch 2
Total questions: 20
Worksheet time: 28mins
What is the correct syntax to output "Hello My Name is Amy" in JavaScript?
println("Hello My Name is Amy")
echo("Hello My Name is Amy");
console.log("Hello My Name is Amy")
printf("Hello My Name is Amy")
What does the typeof operator return for?
Array
Object
String
Boolean
Which of these is a correct way to declare a constant in JavaScript?
const PI = 3.14
let PI = 3.14
var PI = 3.14
const PI = 3,14
What will the following code output?
true
false
undefined
NaN
Which one is the correct code to make the string ALL CAPS?
message = message.toLowerCase()
message = message.toUppercase()
message = message.toupperCase()
message = message.toUpperCase()
Which is the following is a correct arrow function syntax?
function hello ( ) => {
console.log(`Hello`)
}
const hello = ( ) => {
console.log(`Hello`)
}
hello ( ) => {
console.log(`Hello`)
}
hello => console.log('Hello')
How do you create an array in JavaScript?
let arr = "1, 2, 3"
let arr = "[1, 2, 3]"
const arr = "[1, 2, 3]"
const arr = [1, 2, 3]
What is the output of console.log(typeof NaN); ?
number
NaN
undefined
object
Which keyword is used to create a function in JavaScript?
function
Function
class
object
How can you check if a variable x is an array?
x instanceof Array
x == "array"
typeof x === "array"
x.isArray()
What is the purpose of adding async before keyword function?
Enables asynchronous code
Does nothing
Makes the code run faster
Using arrow function
What will this code print?
null
undefined
0
ReferenceError
Which statement is true about using the map() method in JavaScript?
map() changes the original array
map() does not need a return statement
map() creates a new array and usually needs a return
map() is used only for sorting numbers
Which function is used to delay execution in JavaScript?
wait()
setTimeout()
delay()
pause()
What does this function return?
5
undefined
6
NaN
What does this code output of console.log("5" + 1); ?
6
51
NaN
Error
Which keyword allows you to make a variable value changeable?
var
let
const
Which keyword allows you to declare a variable in JavaScript without reassigning or modifying its value afterward?
let
var
const
static
What is the purpose of a try...catch block in JavaScript?
To create a loop
To declare variables
To handle errors in the code
To define functions
Error: y is not defined
Error happened!
y
1
