Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Last active October 6, 2022 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McLarenCollege/7fd9f4d98d608c911d2e848da389673f to your computer and use it in GitHub Desktop.
Save McLarenCollege/7fd9f4d98d608c911d2e848da389673f to your computer and use it in GitHub Desktop.
Sentence Encode

Sentence Encode

Write a function that encodes a given sentence according to the following rules.

  • For words that begin with a vowel (a, e, i, o, u), add "way".
  • Otherwise, move all letters before the first vowel to the end and add "ay".
  • For simplicity, no punctuation will be present in the inputs.

CODE TEMPLATE


function encode(str){
// write code here
}
console.log(encode("this is english language")); // "isthay isway englishway anguagelay"

console.log(encode("wall street journal"));// "allway eetstray ournaljay"

Please watch this video for a hint for the problem:

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