Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

palindrome javascript

// Palindrom or not
// l e v el
const palindrome = (data) => {
  var len = data.length;
  var mid = Math.floor(len / 2);
  for (var i = 0; i < mid; i++) {
    if (data[i] !== data[len - 1 - i]) {
      return false;
    }
  }
  return true;
}
console.log(palindrome("level"))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #palindrome #javascript
ADD COMMENT
Topic
Name
1+8 =