write a javascript program that check if a word is palindrome using one for loop. (palindrome examples: "civic", "noon", "level", "racecar")
function isPalindrome(text) {
text = text.toUpperCase();
for(let i = 0; i < text.length / 2; i++) {
if(text[i] !== text[text.length - 1 - i]) {
return false;
}
}
return true;
}
//Example:
console.log(isPalindrome("noon")); // Output: true
console.log(isPalindrome("racecar")); // Output: true
console.log(isPalindrome("civic")); // Output: true
console.log(isPalindrome("level")); // Output: true
console.log(isPalindrome("tattarrattat")); // Output: true
console.log(isPalindrome("hello")); // Output: false