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.
String searching
Palindromes
Report a typo
Sample Input 1:
Sample Output 1:
true
falseWrite 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"));
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.