Skip to content

Commit

Permalink
demo structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Justine Philip committed Jan 8, 2019
0 parents commit bffec76
Show file tree
Hide file tree
Showing 5 changed files with 5,543 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
25 changes: 25 additions & 0 deletions Beginner/vowelsCounter/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
An iterative approach to counting the number of vowels in a
string of text.
*/

const vowels = ["a", "e", "i", "o", "u"]

function vowelsCounter(text) {
// Initialize counter
let counter = 0;


// Loop through text to test if each character is a vowel
for (let letter of text.toLowerCase()){
if (vowels.includes(letter)) {
counter++
}
}

// Return number of vowels
return counter
}


module.exports = vowelsCounter;
13 changes: 13 additions & 0 deletions Beginner/vowelsCounter/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const vowelsCounter = require('./index');

test('vowelsCounter is a function', () => {
expect(typeof vowelsCounter).toEqual('function');
});

test('returns the number of vowels found', () => {
expect(vowelsCounter('aeiou')).toEqual(5);
});

test('returns the number of vowels found when string is capitalized', () => {
expect(vowelsCounter('AEIOU')).toEqual(5);
});
Loading

0 comments on commit bffec76

Please sign in to comment.