//import java.util.Scanner; public class CountChar { public static void main(String[] args) { //I corrected this with help of the tutorial, then it helped me to solve other problems too. System.out.println(count("book", 'k')); System.out.println(count("book", '0')); System.out.println(count("book", 'b')); } public static int count(String userInput, char character) { int n = 0; for (int i = 0; i < userInput.length(); i++) { if (userInput.charAt(i) == character) { n++; } } return n; } }const str = 'abracadabra' function getCountCodewars(str) { console.log(str.match(/[aeiou]/ig)) // => [ 'a', 'a', 'a', 'a', 'a' ] return (str.match(/[aeiou]/ig) || []).length // => 5 } console.log(getCountCodewars(str)) // => 5