scrimba
Note at 1:29
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 1:29
by Hil
AboutCommentsNotes
Note at 1:29
by Hil
Expand for more info
main.js
run
preview
console
function countVowelConsonant(str) {
// write code here
let newArray = [];
let numbersToAdd = [];
let sum = 0;

newArray = str.split("");

newArray.forEach(str => {
str.toLowerCase();
if (str.match(/^[aeiou]$/)) {
numbersToAdd.push(1)
}
else if (str.match(/^[bcdfghjklmnpqrstvwxyz]$/)) {
numbersToAdd.push(2)
}
});

return sum = numbersToAdd.reduce(function(a, b){
return a + b;
}, 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);
});
});
Console
"result: "
,
8
,
/index.html
LIVE