Quick actions

cmd+k|ctrl+k

Navigation

Languages

hitung huruf

Snippet info

Language

JavaScript

Visibility

public

Author

misbahul.munir0224

Created

2024-09-24T15:16:47.319435Z

Updated

2024-09-24T16:14:52.426268Z

/* buat function dengan dua parameter a dan b. hitung berapa karakter a yg ada dalam kalimat b */
// youtube
function str(a, b) {
    return b.split(a).length -1;
}
console.log(str('a', 'how many times the character occur on this sentence?'));
console.log(str('e', 'how many times the character occur on this sentence?'));
console.log(str('o', 'how many times the character occur on this sentence?'));
console.log(str('t', 'how many times the character occur on this sentence?'));
console.log(str('a', 'how many times the character occur on this sentence?'));
console.log(str('a', 'how many times the character occur on this sentence?'));
console.log(str('a', 'how many times the character occur on this sentence?'));
INFO