Check for a palindrome using Javascript

What is a palindrome?

Oxford Dictionary defines a palindrome as a word, phrase, or sequence that reads the same backwards as forwards, e.g. madam or nurses run.

Let's use Javascript to check if a word is a palindrome

    Function isPalindrome(val){
	Val = val + ''; 

	For(let i = 0, j = val.length - 1; i < j; i++, j--) {
		If(val.charAt(i) !== val.charAt(j)){
			Return false;
		}
	}
	
	Return true;
    }

First, convert a non-string to a string. If the value has a middle character, there is no need to compare it. For example racecar.

isPalindrome(elle)

isPalindrome('rotator')

This is one of many solutions available to check if a word is a palindrome.