How to write a function with a palidrome js code example
Example 1: palindrome in javascript
function palindrome(str) {
var len = str.length;
var mid = Math.floor(len/2);
for ( var i = 0; i < mid; i++ ) {
if (str[i] !== str[len - 1 - i]) {
return false;
}
}
return true;
}
Example 2: how to solve palindrome problem in javascript
function palindrome(str) {
return true;
}
palindrome("eye");