You are viewing a single comment's thread. Return to all comments →
This is mine
const isVowel = (caracter) => ['a','e','i','o','u'].includes(caracter); const printVowel = (caracter) => isVowel(caracter) && console.log(caracter); const printConsonant = (caracter) => !isVowel(caracter) && console.log(caracter); const textLength = (text) => text.length;
const mapText = (text, vowel) => { var i = 0; while(i < textLength(text)){ vowel ? printVowel(text[i]): printConsonant(text[i]); i++; } }
function vowelsAndConsonants(s) { mapText(s, true); mapText(s, false); }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 2: Loops
You are viewing a single comment's thread. Return to all comments →
This is mine
const isVowel = (caracter) => ['a','e','i','o','u'].includes(caracter); const printVowel = (caracter) => isVowel(caracter) && console.log(caracter); const printConsonant = (caracter) => !isVowel(caracter) && console.log(caracter); const textLength = (text) => text.length;
const mapText = (text, vowel) => { var i = 0; while(i < textLength(text)){ vowel ? printVowel(text[i]): printConsonant(text[i]);
i++; } }
function vowelsAndConsonants(s) {
mapText(s, true); mapText(s, false); }