Skip to content

Commit bffec76

Browse files
author
Justine Philip
committed
demo structure
0 parents  commit bffec76

File tree

5 files changed

+5543
-0
lines changed

5 files changed

+5543
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

Beginner/vowelsCounter/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
An iterative approach to counting the number of vowels in a
3+
string of text.
4+
*/
5+
6+
const vowels = ["a", "e", "i", "o", "u"]
7+
8+
function vowelsCounter(text) {
9+
// Initialize counter
10+
let counter = 0;
11+
12+
13+
// Loop through text to test if each character is a vowel
14+
for (let letter of text.toLowerCase()){
15+
if (vowels.includes(letter)) {
16+
counter++
17+
}
18+
}
19+
20+
// Return number of vowels
21+
return counter
22+
}
23+
24+
25+
module.exports = vowelsCounter;

Beginner/vowelsCounter/test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const vowelsCounter = require('./index');
2+
3+
test('vowelsCounter is a function', () => {
4+
expect(typeof vowelsCounter).toEqual('function');
5+
});
6+
7+
test('returns the number of vowels found', () => {
8+
expect(vowelsCounter('aeiou')).toEqual(5);
9+
});
10+
11+
test('returns the number of vowels found when string is capitalized', () => {
12+
expect(vowelsCounter('AEIOU')).toEqual(5);
13+
});

0 commit comments

Comments
 (0)