Skip to content

Instantly share code, notes, and snippets.

@bullishgopher
Created March 30, 2021 17:46
Show Gist options
  • Save bullishgopher/a6278fee431975b0aa8ecc07b037f9fb to your computer and use it in GitHub Desktop.
Save bullishgopher/a6278fee431975b0aa8ecc07b037f9fb to your computer and use it in GitHub Desktop.
const reverse = (data) => {
if ( !data || !data.length) {
return false
}
const length = data.length
const reversed = data.split("").reverse().join("");
for ( let index = 0; index < length / 2; index ++ )
{
if ( data[index] !== reversed[index] )
{
console.log("false")
return false
}
}
console.log("true")
return true
}
reverse("racecar")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment