Single Choice
Easy
QWhat does the following function do in JavaScript?
function isPalindrome(str) {
str = str.toLowerCase();
return str === str.split('').reverse().join('');
}
ID: #4912
Javascript Functions MCQ
237 views
Question Info
#4912Q ID
EasyDifficulty
Javascript Functions MCQTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer
Explanation
This function takes in a single argument, str, and uses the toLowerCase() method to convert the string to lowercase.
It then uses the split(), reverse(), and join() methods to check if the string is a palindrome (i.e., it reads the same forwards and backwards).
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic