Nalini1998 / Project_Public

MIT License
2 stars 0 forks source link

Whale Talk Project #536

Closed Nalini1998 closed 1 year ago

Nalini1998 commented 1 year ago

Take a phrase like ‘turpentine and turtles’ and translate it into its “whale talk” equivalent: ‘UUEEIEEAUUEE’.

Nalini1998 commented 1 year ago
// Completed by @Meow.Nalini98

const input = 'turpentine and turtles';

const vowels = ['a', 'e', 'i', 'o', 'u'];

const resultArray = [];

for (let i=0; i< input.length; i++) {
  console.log(input[i]);
    for (let j=0; j< vowels.length; j++) {
      console.log(vowels[j]);
     if (input[i] === vowels[j]) {
       if (input[i] === 'e') {
          resultArray.push('ee');
      } else if (input[i] === 'u') {
          resultArray.push('uu');   
       } else {
      resultArray.push(input[i]);
        }
      }  
    }
}

// console.log(resultArray);

const resultString = resultArray.join('').toUpperCase();

console.log(resultString);