main.js
1
2
3
4
5
6
7
8
9
10
11
12
function isPalindrome(word) {
  const length = word.length;
  const half = Math.floor(length / 2);
  for (let index = 0; index < half; index++) {
    if (word[index] !== word[length - index - 1]) {
      return false;
    }
  }
  return true;
}
console.log(isPalindrome('madam')); // => true
console.log(isPalindrome('hello')); // => false
Native Browser JavaScript