Count Vowels
JavaScript
Easy
4 views
Problem Description
Given a string, count how many vowels are there (a,e,i,o,u) ignoring case. Print the count.
Input Format
One line string (can have spaces).
Output Format
One integer count.
Constraints
String length up to 1e5.
Official Solution
const fs=require('fs');const s=fs.readFileSync(0,'utf8');const str=s.replace(/\
?\
$/,'');let c=0;for(const ch of str.toLowerCase()){if(ch==='a'||ch==='e'||ch==='i'||ch==='o'||ch==='u')c++;}process.stdout.write(String(c));
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!