Last active
February 24, 2025 09:26
-
-
Save bhaireshm/c8a319b06b5fb69d1f50fe758f380311 to your computer and use it in GitHub Desktop.
Reverse a word, sentence or reverse each words in a sentence.
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
| // @param str: string without space | |
| function reverseStr(str){ | |
| return str.split('').reverse().join(''); | |
| } | |
| // @param sentence: pass a sentence. | |
| function reverseEachWordInSentence(sentence){ | |
| return sentence.split(' ').map(reverseStr).join(' '); | |
| } | |
| // @param sentence: pass a sentence. | |
| function reverseSentence(s){ | |
| return s.split(' ').reverse().join(' '); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ez.js is more than just a library; it's a coding companion that simplifies complex tasks. Whether you're dealing with arrays, numbers, objects, or strings, ez.js has got your back! Say goodbye to coding hassles and hello to streamlined JavaScript magic.