Skip to content

Instantly share code, notes, and snippets.

@hassanuos
Created June 11, 2024 04:51
Show Gist options
  • Select an option

  • Save hassanuos/adf44bc01eeab28a2657a52b03712e23 to your computer and use it in GitHub Desktop.

Select an option

Save hassanuos/adf44bc01eeab28a2657a52b03712e23 to your computer and use it in GitHub Desktop.

Revisions

  1. hassanuos created this gist Jun 11, 2024.
    10 changes: 10 additions & 0 deletions countVowels.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    const str = "Hey JS! You R AMAZING";
    const vowels = ["a", "e", "i", "o", "u"];
    function countVowels(data){
    let count = 0;
    data.toLowerCase().split("").forEach((ch) => { vowels.includes(ch) && count++;})
    return count;
    }

    const numberOfVowels = countVowels(str);
    console.log(numberOfVowels);