We can know how to test whether or not a given worth is a palindrome or now not in JavaScript. A palindrome is a worth that reads the similar from backward or ahead. To accomplish this test we will be able to use the next approaches:
Means 1:Â
Iterate over the string from ahead and backward course
Take a look at if the nature fit
Go back false for the primary personality that doesn’t fitÂ
Go back true if the entire comparisons are carried out and the characters fit
Instance: This situation implements the above method.
Javascript
serve asisPalindrome(str) {
    varj = str.length-1
    for(vari=0; i<str.size/2; i++){
        if(str[i]!=str[j]){
            go backfalse;
        }
        j--;
    }
    go backtrue;
}
 Â
varstr1 = "racecar";
varstr2 = "nitin";
varstr3 = "Rama";
 Â
console.log(isPalindrome(str1));
console.log(isPalindrome(str2));
console.log(isPalindrome(str3));
Output:
true
true
false
Means 2:
Initialize a variable and retailer the opposite of the price in it the use of for loop
Evaluate the unique worth with the reversed worth
If each values are equivalent go back true else go back false
Instance: This situation implements the above method.
Javascript
serve asisPalindrome(str) {
    varrev="";
    for(vari=str.length-1; i>=0; i--){
        rev+= str[i];
    }
    if(rev==str){
        go backtrue
    } else{
        go backfalse;
    }
}
 Â
varstr1 = "racecar";
varstr2 = "nitin";
varstr3 = "Rama";
 Â
console.log(isPalindrome(str1));
console.log(isPalindrome(str2));
console.log(isPalindrome(str3));
Output:
true
true
false
Means 3:Â
Use in-built string strategies like cut up() to separate the string into characters array