Sort by

recency

|

766 Discussions

|

  • + 0 comments

    THIS IS MINE:

    function vowelsAndConsonants(s) {
        const VOWLES = new Set(['a', 'e', 'i', 'o', 'u']);
        let sConsonants = '';
        
        for (let char of s) {
            VOWLES.has(char) ? console.log(char) : sConsonants += char + '\n';
        }
    
        console.log(sConsonants);
    }
    
  • + 0 comments

    To add to the multiple solutions posted, this was my method:

    function vowelsAndConsonants(s) {

    const vowelArray = ["a", "e", "i", "o", "u"];
    let outputVowel = ""; 
    let outputConsonant = ""; 
    
    for (let i = 0, len = s.length; i < len; i++) {
    
        if (vowelArray.includes(s[i])) {
            outputVowel += s[i] + '\n';
        } else {
            outputConsonant += s[i] + '\n';
    
        }
    
    }
    
    console.log(outputVowel + outputConsonant)
    

    }

  • + 0 comments
    function vowelsAndConsonants(s) {
        let vowelsArray = ['a','e','i','o','u'];
        let vowels = []
        let consonants = []
    
        for(let char of s) {
            vowelsArray.includes(char) ? vowels.push(char) : consonants.push(char)
        }
    
        let vowels_and_consonant = [...vowels, ...consonants]
        vowels_and_consonant.forEach(elem => console.log(elem))
    
    }
    
  • + 0 comments

    Newby, doing things very slowly, but thouroughly. Method goes throught the string twice, Once for vowels, and second time for consonants.

    function vowelsAndConsonants(s) { for (let x = 0; x < s.length; x++){ if(s[x]=='a' || s[x]=='e' || s[x]=='i' || s[x]=='o' || s[x]=='u'){ console.log(s[x]) } } for (let x = 0; x < s.length; x++){ if (s[x]!='a' && s[x]!='e' && s[x]!='i' && s[x]!='o' && s[x]!='u'){ console.log(s[x]) } } }

  • + 0 comments
    function vowelsAndConsonants(s) {
        for (let i = 0; i < s.length; i++) {
            if (s[i] == "a" || s[i] == "e" || s[i] == "i" || s[i] == "o" || s[i] == "u"){
                console.log(s[i])
            }
        }
        
         for (let i = 0; i < s.length; i++) {
            if (s[i] !== "a" && s[i] !== "e" && s[i] !== "i" && s[i] !== "o" && s[i] !== "u"){
                console.log(s[i])
            }
        }
    }