Don't forget to hit the ⭐ if you like this repo.
Please answer the following 50 multiple-choice questions to test your knowledge in JavaScript fundamentals. You must place your answer file in the submission folder. Within the submission/Q1/set_a
folder, create a folder called your github_id
.
-
What is JavaScript primarily used for?
- a) Creating stylish webpage layouts
- b) Adding interactivity to websites
- c) Storing and managing databases
- d) Designing server infrastructure
-
Which keyword is used to declare a variable in JavaScript?
- a)
var
- b)
let
- c)
const
- d) All of the above
- a)
-
Which data type is not supported in JavaScript?
- a) Numbers
- b) Strings
- c) Booleans
- d) Characters
-
What is the result of
typeof null
in JavaScript?- a)
"null"
- b)
"object"
- c)
"undefined"
- d)
"string"
- a)
-
How do you add a comment in JavaScript?
- a)
// This is a comment
- b)
/* This is a comment */
- c)
<!-- This is a comment -->
- d)
# This is a comment
- a)
-
Which operator is used for concatenating strings in JavaScript?
- a)
+
- b)
-
- c)
*
- d)
/
- a)
-
What is the output of
2 + "2"
in JavaScript?- a)
4
- b)
"22"
- c)
"4"
- d)
NaN
- a)
-
Which statement is used to exit a loop in JavaScript?
- a)
break
- b)
continue
- c)
return
- d)
exit
- a)
-
What does the
document.getElementById()
method in JavaScript do?- a) Retrieves an element by its class name
- b) Retrieves an element by its tag name
- c) Retrieves an element by its id
- d) Retrieves an element by its attribute
-
Which function is used to convert a string to an integer in JavaScript?
- a)
parseInt()
- b)
parseFloat()
- c)
toFixed()
- d)
toString()
- a)
-
How do you declare a function in JavaScript?
- a)
function myFunction() {}
- b)
var myFunction() {}
- c)
const myFunction() {}
- d)
let myFunction() {}
- a)
-
What is the result of
5 == "5"
in JavaScript?- a)
true
- b)
false
- c)
undefined
- d)
NaN
- a)
-
Which method is used to remove the last element from an array in JavaScript?
- a)
pop()
- b)
push()
- c)
shift()
- d)
unshift()
- a)
-
What does the
setTimeout()
function do in JavaScript?- a) Pauses the execution of the code for a specified duration
- b) Executes a function after a specified delay
- c) Adds an event listener to an element
- d) Modifies the style of an element
-
What is the purpose of the
this
keyword in JavaScript?- a) Refers to the current object or context
- b) Declares a new variable
- c) Defines a JavaScript class
- d) Accesses an external API
-
How do you check the length of an array in JavaScript?
- a)
length()
- b)
count()
- c)
size()
- d)
length
- a)
-
Which method is used to convert a JavaScript object to a JSON string?
- a)
parse()
- b)
stringify()
- c)
convert()
- d)
serialize()
- a)
-
What does the
NaN
value represent in JavaScript?- a) "Not a Number"
- b) "Null and Notable"
- c) "Negative Arithmetic Number"
- d) "No Action Necessary"
-
How do you create a new object in JavaScript?
- a)
new Object()
- b)
createObject()
- c)
Object.create()
- d) All of the above
- a)
-
Which keyword is used to throw an exception in JavaScript?
- a)
exception
- b)
error
- c)
throw
- d)
catch
- a)
-
What is the output of
typeof []
in JavaScript?- a)
"array"
- b)
"object"
- c)
"array-object"
- d)
"undefined"
- a)
-
Which operator is used to check for strict equality in JavaScript?
- a)
==
- b)
!=
- c)
===
- d)
!==
- a)
-
What does the
splice()
method do in JavaScript?- a) Adds elements to the beginning of an array
- b) Removes elements from an array
- c) Sorts the elements of an array
- d) Converts an array to a string
-
Which method is used to add a new element to the end of an array in JavaScript?
- a)
push()
- b)
pop()
- c)
shift()
- d)
unshift()
- a)
-
How do you access the length of a string in JavaScript?
- a)
length()
- b)
size()
- c)
count()
- d)
length
- a)
-
Which method is used to convert a string to uppercase in JavaScript?
- a)
toUpperCase()
- b)
toLowerCase()
- c)
trim()
- d)
charAt()
- a)
-
What does the
addEventListener()
method do in JavaScript?- a) Modifies the style of an element
- b) Removes an event listener from an element
- c) Adds an event listener to an element
- d) Retrieves an element by its id
-
How do you round a number to the nearest integer in JavaScript?
- a)
round()
- b)
floor()
- c)
ceil()
- d)
toFixed()
- a)
-
What is the purpose of the
map()
method in JavaScript?- a) Iterates over the elements of an array and performs a callback function on each element
- b) Removes elements from an array based on a specified condition
- c) Sorts the elements of an array in ascending order
- d) Converts an array to a string
-
Which operator is used to access a property of an object in JavaScript?
- a)
:
- b)
.
- c)
=>
- d)
@
- a)
-
What is the output of
console.log(typeof NaN)
in JavaScript?- a)
"number"
- b)
"undefined"
- c)
"NaN"
- d)
"object"
- a)
-
How do you convert a JavaScript object to an array?
- a)
Object.values()
- b)
Object.keys()
- c)
Object.entries()
- d) All of the above
- a)
-
What does the
substring()
method do in JavaScript?- a) Extracts a section of a string and returns a new string
- b) Removes leading and trailing spaces from a string
- c) Converts a string to uppercase
- d) Converts a string to lowercase
-
Which method is used to sort the elements of an array in JavaScript?
- a)
sort()
- b)
reverse()
- c)
concat()
- d)
slice()
- a)
-
How do you convert a string to an array in JavaScript?
- a)
split()
- b)
join()
- c)
concat()
- d)
splice()
- a)
-
What is the output of
console.log(2 + 2 + "2")
in JavaScript?- a)
"4"
- b)
"22"
- c)
"222"
- d)
"NaN"
- a)
-
What is the purpose of the
reduce()
method in JavaScript?- a) Applies a callback function against an accumulator and each element in an array to reduce it to a single value
- b) Filters the elements of an array based on a specified condition
- c) Adds new elements to the beginning of an array
- d) Reverses the order of the elements in an array
-
How do you check if a variable is an array in JavaScript?
- a)
Array.isArray()
- b)
typeof
- c)
instanceof
- d)
isArray()
- a)
-
Which method is used to remove leading and trailing spaces from a string in JavaScript?
- a)
trim()
- b)
toUpperCase()
- c)
toLowerCase()
- d)
charAt()
- a)
-
What does the
toFixed()
method do in JavaScript?- a) Returns the specified number of decimal places as a string
- b) Rounds a number to the nearest integer
- c) Returns the square root of a number
- d) Returns the absolute value of a number
-
How do you access the value of an input field in JavaScript?
- a)
document.getValue()
- b)
inputField.value
- c)
inputField.getValue()
- d)
document.getElement(inputField).value
- a)
-
Which method is used to find the index of a specified value in an array in JavaScript?
- a)
indexOf()
- b)
findIndex()
- c)
search()
- d)
includes()
- a)
-
What is the output of
console.log(2 * "2")
in JavaScript?- a)
4
- b)
"4"
- c)
"22"
- d)
NaN
- a)
-
How do you convert a number to a string in JavaScript?
- a)
String()
- b)
Number.toString()
- c)
parseInt()
- d)
toFixed()
- a)
-
What does the
Math.random()
function do in JavaScript?- a) Returns a random integer between 0 and 1
- b) Generates a random number between a specified range
- c) Returns the square root of a number
- d) Rounds a number to the nearest integer
-
Which method is used to remove an event listener from an element in JavaScript?
- a)
removeEventListener()
- b)
addEventListener()
- c)
getElementById()
- d)
querySelector()
- a)
-
How do you convert a string to lowercase in JavaScript?
- a)
toLowerCase()
- b)
toUpperCase()
- c)
trim()
- d)
charAt()
- a)
-
What is the output of
console.log(5 > 2 && 3 < 6)
in JavaScript?- a)
true
- b)
false
- c)
undefined
- d)
NaN
- a)
-
Which method is used to find the highest value in an array in JavaScript?
- a)
Math.max()
- b)
Math.min()
- c)
findMax()
- d)
findMin()
- a)
-
How do you convert a string to uppercase in JavaScript?
- a)
toUpperCase()
- b)
toLowerCase()
- c)
trim()
- d)
charAt()
- a)
Please create an Issue for any improvements, suggestions or errors in the content.
You can also contact me using Linkedin for any other queries or feedback.