You are viewing a single comment's thread. Return to all comments →
Did we have to use the for loop? I used map... like this maybe it isn't the best way and advice is great
'use strict'; function vowelsAndConsonants(s) { const vowels = ['a','e','i','o','u']; const resultsVowels = []; const resultsConst= []; s.split('').map((letter) => { vowels.includes(letter) ? resultsVowels.push(letter) : resultsConst.push(letter); }) const results = resultsVowels.join('') + resultsConst.join(''); results.split('').forEach((l) => console.log(l)); }
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 →
Did we have to use the for loop? I used map... like this maybe it isn't the best way and advice is great