Approaching a Palindrome Algorithm

--- DirectionsGiven a string, return true if the string is a palindrome or false if it is not. Palindromes are strings that form the same word if it is reversed. *Do* include spaces and punctuation in determining if the string is a palindrome.--- Examples://   palindrome("dad") === true//   palindrome("hey") === falsefunction palindrome(str) {}
  1. Compare the string to the reversed string to return true or false
Palindrome — Solution 1
let reversed = "cool"reversed.split('')
=> [ 'c', 'o', 'o', 'l' ]
[ 'c', 'o', 'o', 'l' ].reverse()
=> [ 'l', 'o', 'o', 'c' ]
[ 'l', 'o', 'o', 'c' ].join('')
=> 'looc'

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store