Created
March 30, 2021 17:46
-
-
Save xgracias/a6278fee431975b0aa8ecc07b037f9fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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