Skip to content

Commit 7516701

Browse files
author
Coding Money
committed
vowels
1 parent d74f454 commit 7516701

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

Diff for: .DS_Store

6 KB
Binary file not shown.

Diff for: completed_exercises/7-vowels.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// --- Directions
2+
// Write a function that returns the number of vowels
3+
// used in a string. Vowels are the characters 'a', 'e'
4+
// 'i', 'o', and 'u'.
5+
// --- Examples
6+
// vowels('Hi There!') --> 3
7+
// vowels('How are you?') --> 5
8+
// vowels('Coding Money') --> 4
9+
// vowels('why?') --> 0
10+
11+
function vowels(str) {
12+
const vowelCheck = ['a', 'e','i', 'o', 'u']
13+
14+
let count = 0
15+
16+
for(let char of str){
17+
if(vowelCheck.includes(char)) count++
18+
}
19+
20+
return count
21+
}
22+
23+
console.log(vowels('Coding Money'));
24+
25+
// function vowels(str) {
26+
// const matches = str.match(/[aeiou]/gi)
27+
// return matches ? matches.length : 0
28+
// }

Diff for: exercises/7-vowels.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// --- Directions
2+
// Write a function that returns the number of vowels
3+
// used in a string. Vowels are the characters 'a', 'e'
4+
// 'i', 'o', and 'u'.
5+
// --- Examples
6+
// vowels('Hi There!') --> 3
7+
// vowels('How are you?') --> 5
8+
// vowels('Coding Money') --> 4
9+
// vowels('why?') --> 0
10+
11+
function vowels(str) {}
12+
13+
console.log(vowels('Coding Money'));

0 commit comments

Comments
 (0)