scrimba
Note at 0:46
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Note at 0:46
AboutCommentsNotes
Note at 0:46
Expand for more info
main.js
run
preview
console
function countVowelConsonant(str) {
const vowels = ['a','e','i','o','u']
return str.split('').reduce((acc, value) =>
acc += vowels.some(vowel => value.includes(vowel)) ? 1 : 2,0)
}



/**
* Test Suite
*/
describe('countVowelConsonant()', () => {
it('returns total of vowels(1) and consonants(2) to be added', () => {
// arrange
const value = 'abcde';

// act
const result = countVowelConsonant(value);

// log
console.log("result: ", result);

// assert
expect(result).toBe(8);
});
it('returns total of vowels(1) and consonants(2) to be added', () => {
// arrange
const value = 'aaeeiioouu';

// act
const result = countVowelConsonant(value);

// log
console.log("result: ", result);

// assert
expect(result).toBe(10);
});
it('returns total of vowels(1) and consonants(2) to be added', () => {
// arrange
const value = 'bcdfghjklmnp';

// act
const result = countVowelConsonant(value);

// log
console.log("result: ", result);

// assert
expect(result).toBe(24);
});
});
Console
"result: "
,
10
,
"result: "
,
8
,
"result: "
,
24
,
/index.html
LIVE