fork download
  1. function magic(s) {
  2. let v = ["a", "e", "i", "o", "u"];
  3. let r = "";
  4.  
  5. for (let i = 0; i < s.length; i++) {
  6. if (v.includes(s[i])) r += s[i].toUpperCase();
  7. else r += s[i];
  8. }
  9.  
  10. r = r.split("").reverse();
  11. if (!v.includes(r[r.length])) r.pop();
  12.  
  13. return r.join("-");
  14. }
  15.  
  16. console.log(magic("hellothere")); // E-r-E-h-t-O-l-l-E
Success #stdin #stdout 0.04s 17124KB
stdin
Standard input is empty
stdout
E-r-E-h-t-O-l-l-E