Sort by

recency

|

774 Discussions

|

  • + 0 comments
    // 1
    
    // function vowelsAndConsonants(s) {
    //     const vowels = 'aeiou';
    
    //     for (let index = 0; index < s.length; index++) {
    //         if (vowels.includes(s[index])) {
    //             console.log(s[index]);
    //         }
    //     }
    
    //     for (let index = 0; index < s.length; index++) {
    //         if (!vowels.includes(s[index])) {
    //             console.log(s[index]);
    //         }
    //     }
    // }
    
    
    // 2
    
    // function vowelsAndConsonants(s) {
    //     const vowels = 'aeiou';
    
    //     // output vowels
    //     for (let i = 0; i < s.length; i++) {
    //         if (vowels.indexOf(s.charAt(i)) > -1) {
    //             console.log(s.charAt(i));
    //         }
    //     }
    
    //     // output consonants
    //     for (let i = 0; i < s.length; i++) {
    //         if (vowels.indexOf(s.charAt(i)) < 0) {
    //             console.log(s.charAt(i));
    //         }
    //     }
    // }
    
    // 3 
    
    // function vowelsAndConsonants(s) {
    //     const vowels = 'aeiou';
    //     s = s.split(''); 
    
    //     // output vowels
    //     s.forEach((i) => {
    //         if (vowels.indexOf(i) > -1) {
    //             console.log(i);
    //         }
    //         return i;
    //     });
    
    //     // output consonants
    //     s.forEach((i) => {
    //         if (vowels.indexOf(i) < 0) {
    //             console.log(i);
    //         }
    //         return i;
    //     });
    // }
    
    // 4
    
    // function vowelsAndConsonants(s) {
    //     let vowels = ["a", "e", "i", "o", "u"];
    
    //     for (let v of s) {
    //         if (vowels.includes(v)) {
    //             console.log(v);
    //         }
    //     }
    
    //     for (let v of s) {
    //         if (!vowels.includes(v)) {
    //             console.log(v);
    //         }
    //     }
    // }
    
    // 5 My Solution
    
    function vowelsAndConsonants(s) {
        let vowels = ['a', 'e', 'i', 'o', 'u'];
    
        for (let i = 0; i < s.length; i++) {
            if (vowels.includes(s[i])) {
                console.log(s[i]);
            }
        }
    
        for (let i = 0; i < s.length; i++) {
            if (!vowels.includes(s[i])) {
                console.log(s[i]);
            }
        }
    }
    
  • + 0 comments

    function vowelsAndConsonants(s) { let vowel =[] let cons =[] let ans =[] for(var i=0; i

  • + 0 comments

    I must have done mine like the cave men, lol

    function vowelsAndConsonants(s) {
        for (let i = 0; i < s.length; i++) { //loop through the first time to find vowels
            if (s[i] == "a") {
                console.log(s[i])
            }
            else if (s[i] == "e") {
                console.log(s[i])
            }
            else if (s[i] == "o") {
                console.log(s[i])
            }
            else if (s[i] == "i") {
                console.log(s[i])
            }
            else if (s[i] == "u") {
                console.log(s[i])
            }
        }
        for (let j = 0; j < s.length; j++) { //loop through second time to find consonants
            if (s[j] == "a") {
                continue
            }
            else if (s[j] == "e") {
                continue
            }
            else if (s[j] == "o") {
                continue
            }
            else if (s[j] == "i") {
                continue
            }
            else if (s[j] == "u") {
                continue
            }
            else {
                console.log(s[j])
            }
    
    }
    

    } `

  • + 0 comments

    this is my solution:

        let consonantes = [];
        for(let i = 0; i < s.length; i++) {
            if ("aeiou".includes(s[i])) {
                console.log(s[i]);
            } else {
                consonantes.push(s[i]);
            }
        }
        for (let j = 0; j < consonantes.length; j++) {
            console.log(consonantes[j]);
        }
    }
    
  • + 0 comments

    this is my solution:

    function vowelsAndConsonants(s) {    
        const voewls = s.match(/[aeiou]/g)
        const consonants = s.match(/[^aeiou]/g)
        voewls.forEach(char => console.log(char))
        consonants.forEach(char => console.log(char))
    }