const wordReverse = (string) => {
return string.split("").reverse().join("")
}
console.log(wordReverse("This is how we do it."))
//.split creates an array=['T', 'h', 'i', 's', ' ', 'i', 's', ' ', 'h', 'o', 'w', ' ', 'w', 'e', ' ', 'd', 'o', ' ', 'i', 't', '.']
//.reverse simply reversese the array
//.join puts the elements of the string back together in a string
Created
June 19, 2021 22:55
-
-
Save tripdog/c465f5d48c94222901ba9cdbdbda9a8b to your computer and use it in GitHub Desktop.
Create a function called `wordReverse` that reverses a string using built-in JS methods
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment