Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created August 22, 2023 06:19
Show Gist options
  • Save codecademydev/e9772f2b0ca2964ba9870f8ff615ac20 to your computer and use it in GitHub Desktop.
Save codecademydev/e9772f2b0ca2964ba9870f8ff615ac20 to your computer and use it in GitHub Desktop.
Codecademy export
const input = 'a whale of a deal!';
const vowels = ['a','e','i','o','u'];
const resultArray = [];
for(let inputIndex = 0 ; inputIndex < input.length ; inputIndex++){
//console.log(`input is ${inputIndex}`);
if(input[inputIndex] === 'a'){
resultArray.push(input[inputIndex])
}
if(input[inputIndex] === 'e'){
resultArray.push(input[inputIndex])
}
for(let vowelsIndex = 0; vowelsIndex < vowels.length; vowelsIndex++){
//console.log(`vowelsIndex is ${vowelsIndex}`);
if (input[inputIndex] === vowels[vowelsIndex]){
console.log(input[inputIndex]);
resultArray.push(input[inputIndex]);
}
}
}
console.log(resultArray.join(' ').toUpperCase());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment