Last active
December 18, 2022 18:31
-
-
Save Hacking-NASSA-with-HTML/a68301447fe3e097da1ef2c53627e7b9 to your computer and use it in GitHub Desktop.
Function to reverse the order of characters in a word:
This file contains 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
// function to reverse the order of characters in a word: | |
function reverse(word) { | |
let reversedWord = '' | |
for (let i = word.length - 1; i >= 0; i--) { | |
reversedWord = reversedWord.concat(word[i]) | |
} | |
return reversedWord | |
} | |
console.log(reverse('word')) // prints drow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment