Fundamentals of Front End Development MCQs with Answers
Practice important Fundamentals of Front End Development MCQs with answers and explanations.
Chapter: 70
Q801:
Fill in the blank: The concat() method is used to ________.
A. Remove elements from an array
B. Create a new array by joining two arrays
C. Sort an array
D. Reverse the elements in an array
Correct Answer:
B
Chapter: 70
Q802:
What does the slice() method return when used with fruits.slice(1, 3) if fruits is ["Banana", "Orange", "Lemon", "Apple", "Mango"]?
A. ["Banana", "Orange"]
B. ["Orange", "Lemon", "Apple"]
C. ["Orange", "Lemon"]
D. ["Lemon", "Apple"]
Correct Answer:
C
Chapter: 70
Q803:
What will be the result of points.sort(function(a, b){return a-b}) if points is [40, 100, 1, 5, 25, 10]?
A. [1, 5, 10, 25, 40, 100]
B. [100, 40, 25, 10, 5, 1]
C. [40, 100, 25, 10, 5, 1]
D. [1, 5, 25, 40, 10, 100]
Correct Answer:
A
Chapter: 70
Q804:
Fill in the blank: When comparing two values, if the compare function returns a negative value, the first value is ________.
A. Greater than the second value
B. Smaller than the second value
C. Equal to the second value
D. None of the above
Correct Answer:
B
Chapter: 70
Q805:
What will myChildren be after executing myChildren = myGirls.concat(myBoys) if myGirls is ["Aisha", "Meryam"] and myBoys is ["Bilal", "Umer", "Ali"]?
A. ["Aisha", "Meryam", "Bilal", "Umer", "Ali"]
B. ["Aisha", "Meryam"]
C. ["Bilal", "Umer", "Ali"]
D. ["Aisha", "Meryam", "Ali"]
Correct Answer:
A
Chapter: 70
Q806:
Fill in the blank: The sort() method requires a ________ to define how the elements should be sorted.
A. String function
B. Compare function
C. Number function
D. Value function
Correct Answer:
B
Chapter: 70
Q807:
What will be the output of fruits.slice(2) if fruits is ["Banana", "Orange", "Lemon", "Apple", "Mango"]?
A. ["Lemon", "Apple", "Mango"]
B. ["Banana", "Orange", "Lemon"]
C. ["Lemon", "Apple"]
D. ["Orange", "Lemon", "Apple", "Mango"]
Correct Answer:
A
Chapter: 71
Q808:
What does the === operator check for in JavaScript?
A. Only value equality
B. Only type equality
C. Both value and type equality
D. Only type difference
Correct Answer:
C
Chapter: 71
Q809:
Fill in the blank: The operator !== checks if the values and types are ________.
A. Equal
B. Not equal
C. Greater than
D. Less than
Correct Answer:
B
Chapter: 71
Q810:
What will the conditional operator return if the age is 20 and the condition is age < 18?
A. "Too young"
B. "Old enough"
C. "Error in input"
D. null
Correct Answer:
B
Chapter: 71
Q811:
Fill in the blank: The ternary operator has the syntax ________.
A. condition ? value1 : value2
B. value1 : condition ? value2
C. value1 ? condition : value2
D. condition : value1 ? value2
Correct Answer:
A
Chapter: 71
Q812:
What does the ! operator do in JavaScript?
A. Negates the value
B. Converts the value to a string
C. Converts the value to a number
D. Checks equality
Correct Answer:
A
Chapter: 71
Q813:
Fill in the blank: To compare different data types correctly, variables should be ________.
A. Ignored
B. Converted to proper type
C. Directly compared
D. Kept as strings
Correct Answer:
B
Chapter: 72
Q814:
Which JavaScript statement specifies a block of code to execute if a condition is true?
A. if
B. else
C. else if
D. switch
Correct Answer:
A
Chapter: 72
Q815:
What does the `else` statement do in JavaScript?
A. It specifies a block of code to execute if the condition is true
B. It specifies a block of code to execute if the condition is false
C. It specifies a new condition to test if the first condition is true
D. It specifies many alternative blocks of code to execute
Correct Answer:
B
Chapter: 72
Q816:
What is the purpose of the `else if` statement in JavaScript?
A. It specifies a new condition to test if the first condition is true
B. It specifies a block of code to execute if the condition is false
C. It specifies a block of code to execute if the condition is true
D. It specifies many alternative blocks of code to execute
Correct Answer:
A
Chapter: 72
Q817:
What will the following code output if `hour` is 16? `if (hour < 18) { greeting = "Good day"; } else { greeting = "Good evening"; }`
A. Good morning
B. Good day
C. Good evening
D. No output
Correct Answer:
B
Chapter: 72
Q818:
In the given code, what greeting will be created if `time` is 12? `if (time < 10) { greeting = "Good morning"; } else if (time < 20) { greeting = "Good day"; } else { greeting = "Good evening"; }`
A. Good morning
B. Good day
C. Good evening
D. Error
Correct Answer:
B
Chapter: 72
Q819:
Which statement is used to specify many alternative blocks of code to be executed?
A. if
B. else
C. else if
D. switch
Correct Answer:
D
Chapter: 72
Q820:
What will the following code snippet output if `time` is 9? `if (time < 10) { greeting = "Good morning"; } else if (time < 20) { greeting = "Good day"; } else { greeting = "Good evening"; }`
A. Good morning
B. Good day
C. Good evening
D. No output
Correct Answer:
A