Advertisement
makispaiktis

5. Codecademy Intro - Whale Talk

Oct 18th, 2024
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let input = "Hello humans";
  2. const vowels = ["a", "e", "i", "o", "u"];
  3. let resultArray = [];
  4.  
  5. // Letters 'e' and 'u' will be double times in our resultArray
  6. // while the other 3 vowels ('a', 'i', 'o') will appear once
  7. for(let i=0; i<input.length; i++){
  8.     letter = input[i];
  9.     if(letter === 'e' || letter === 'u'){
  10.         resultArray.push(letter);
  11.     }
  12.     for(let j=0; j<vowels.length; j++){
  13.         vowel = vowels[j];
  14.         if(letter === vowel){
  15.             resultArray.push(letter);
  16.         }
  17.     }
  18. }
  19.  
  20. resultString = resultArray.join('');
  21. resultString = resultString.toUpperCase();
  22. console.log(resultString);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement