Skip to content

Commit 0b67ee6

Browse files
committed
refactor isEven in chapter_3
1 parent ffcc725 commit 0b67ee6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

chapter_three.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ function isEven(n) {
1717
if (n === -1) return false;
1818
else return isEven(n + 2);
1919
}
20-
if (n === 0) {
21-
return true;
22-
}
20+
if (n === 0) return true;
2321
}
2422

25-
console.log(isEven(-50));
23+
console.log(isEven(-7));
2624

2725
//count beans - write a function that takes a string argument and returns the number of uppercase Bs in it
2826

@@ -36,6 +34,8 @@ function countBs(word) {
3634

3735
console.log(countBs('BBC'));
3836

37+
//count characters - write a function that takes two string arguments: a word and a letter and counts the given letter's occurences in the given word
38+
3939
function countChar(word, char) {
4040
let count = 0;
4141
for (let i = 0; i < word.length; i++) {

0 commit comments

Comments
 (0)