scrimba
Solution for day 7 of #javascriptmas
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

Solution for day 7 of #javascriptmas
AboutCommentsNotes
Solution for day 7 of #javascriptmas
Expand for more info
main.js
run
preview
console
function countVowelConsonant(str) {
// write code here
let strCount = 0
for (let i = 0; i < str.length; i++) {
console.log(str[i])
console.log(strCount)
if (str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u') {
strCount++
} else {
strCount += 2
}
}

return strCount
}



/**
* 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
"a"
,
0
,
"b"
,
1
,
"c"
,
3
,
"d"
,
5
,
"e"
,
7
,
"result: "
,
8
,
/index.html
LIVE