By using our mini forum, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy

Q: Palindrome – Symmetry Check in JavaScript

+5 votes

Write a JS function (program) that checks if an input string is a palindrome. See what is a palindrome:

The input comes as a single string argument.


Input: haha

Output: false

Input: racecar

Output: true

Input: unitinu

Output: true

The output is the return value of your function. It should be true if the string is a palindrome and false if it’s not.

asked in JavaScript category by user eiorgert
edited by user golearnweb

1 Answer

+3 votes

Here is my palindrome:

 * @param str {string}
 * @returns {boolean}

function isPalindrome(str) {
    for (let i = 0; i < str.length / 2; i++) {
        if (str[i] != str[str.length - i - 1]) {
            return false;
    return true;

answered by user hues