Palindromes

Report a typo

A palindrome string is a string that looks unchanged if reversed. The code below checks if a given string is a palindrome or not. Use the charAt() method on the string and complete the function.

Sample Input 1:

Sample Output 1:

true
false
Write a program in JavaScript
function isPalindrome(userStr) {
for (let letter = 0; letter < userStr.length / 2; letter++) {
if (userStr... !== userStr.charAt(...)) {
return false;
}
}
return true;
}

console.log(isPalindrome("racecar"));
console.log(isPalindrome("javascript"));
___

Create a free account to access the full topic