Skip to content

Instantly share code, notes, and snippets.

@bhaireshm
Last active February 24, 2025 09:26
Show Gist options
  • Select an option

  • Save bhaireshm/c8a319b06b5fb69d1f50fe758f380311 to your computer and use it in GitHub Desktop.

Select an option

Save bhaireshm/c8a319b06b5fb69d1f50fe758f380311 to your computer and use it in GitHub Desktop.
Reverse a word, sentence or reverse each words in a sentence.
// @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(' ');
}
@bhaireshm
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment