Count Vowels in a String

Easy Strings
Count how many vowels (a, e, i, o, u) appear in a string, ignoring case.

Sample input

education

Sample output

5

Solution

s = "education"
count = sum(1 for ch in s.lower() if ch in "aeiou")
print(count)
const s = "education";
const count = (s.match(/[aeiou]/gi) || []).length;
console.log(count);
public class Main {
    public static void main(String[] args) {
        String s = "education";
        int count = 0;
        for (char c : s.toLowerCase().toCharArray()) {
            if ("aeiou".indexOf(c) != -1) count++;
        }
        System.out.println(count);
    }
}
fun main() {
    val s = "education"
    val count = s.count { it.lowercaseChar() in "aeiou" }
    println(count)
}
let s = "education"
let vowels = Set("aeiou")
let count = s.lowercased().filter { vowels.contains($0) }.count
print(count)
void main() {
  String s = 'education';
  int count = 0;
  for (var ch in s.toLowerCase().split('')) {
    if ('aeiou'.contains(ch)) count++;
  }
  print(count);
}
#include <iostream>
#include <cctype>
#include <string>
using namespace std;

int main() {
    string s = "education";
    int count = 0;
    for (char c : s) {
        c = tolower(c);
        if (string("aeiou").find(c) != string::npos) count++;
    }
    cout << count << endl;
    return 0;
}
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main() {
    char s[] = "education";
    int count = 0;
    for (int i = 0; s[i]; i++) {
        char c = tolower(s[i]);
        if (strchr("aeiou", c)) count++;
    }
    printf("%d\n", count);
    return 0;
}