Question #83423

How to check if word is palindrome using one for loop in javascript? (palindrome examples: "noon", "racecar")

Expert's answer

var str = "helloolleh";

var answer = true;

for(var i = 0, j = str.length - 1; i<j; i++, j--){

if(str[i] != str[j]) {

answer = false;

break;

}

};


if(answer == false){

console.log("This string isnt pallendrom");

}

else console.log("String is pallendrom");

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS