fork(1) download
  1. function temp(str) {
  2.  
  3. const vowelMap = {
  4. a: "ant",
  5. e: "ex",
  6. i: "ishq",
  7. o: "off",
  8. u: "ufo"
  9. };
  10.  
  11.  
  12. return str.split('').forEach(function(c, ans) {
  13. console.log(vowelMap[c.toLowerCase()]);
  14.  
  15. (c == ' ' || (vowelMap[c.toLowerCase()] === undefined)) ? ans+=c : ans+= (c + vowelMap[c.toLowerCase()]);
  16. console.log(ans);
  17. return ans;
  18. });
  19. }
  20.  
  21.  
  22. const x = temp("I love water");
  23. console.log(x);
Success #stdin #stdout 0.03s 17284KB
stdin
Standard input is empty
stdout
ishq
0Iishq
undefined
1 
undefined
2l
off
3ooff
undefined
4v
ex
5eex
undefined
6 
undefined
7w
ant
8aant
undefined
9t
ex
10eex
undefined
11r
undefined