fork download
  1. // your code goes here//convert all vowels in the string to uppercase
  2. function vowelToUppercase(s) {
  3.  
  4. return s.replace(/[aeiou]/g, (c) => c.toUpperCase());
  5. }
  6.  
  7. console.log(vowelToUppercase('Hello Afnane'));
  8.  
  9. //reverse the string
  10. function reverse(s){
  11. return s.split('').reverse().join('');
  12. }
  13.  
  14. console.log(reverse('Afnane'));
  15.  
  16. //Removing last char if consonant
  17. function removeConsonant(s){
  18. let lastChar = s.charAt(s.lenght - 1);
  19. if (/[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ]/.test(lastChar)){
  20. return s.slice(0,-1);
  21. }
  22. return s;
  23. }
  24.  
  25. console.log(removeConsonant('Hello Afnane'));
  26. //magic function
  27. function magic(s){
  28. return s.split('').join('-');
  29.  
  30. }
  31.  
  32. console.log(magic('Hello Afnane'));
Success #stdin #stdout 0.04s 18724KB
stdin
Standard input is empty
stdout
HEllO AfnAnE
enanfA
Hello Afnan
H-e-l-l-o- -A-f-n-a-n-e