This is my solutions to the exercises, the first one I did just with my understanding from everything that I have read in the book and from the examples, when the guy in the book is trying to explain the exercise what we need to do, I really do not understand him… I feel like I need to decode him first … In the second exercise I tried to do it even if I didn’t understand him what he wanted to say… Got it half working but just the opposite of what he wanted hahaha. The third one, again I didn’t understand until I looked for the answers on the forum and they really seemed to be explained well so it helped me alot to figure out how are they working. I did exercises couple of times, until I got the better understanding of them and how to do them withouth looking at the answers. By doing I get better understanding of them and why is something placed in the way it is
function min(a,b) {
if (a<b) return (a);
else return (b);
}
function isEven(n) {
if (n == 0) return true;
else if (n == 1) return false;
else if (n < 0) return isEven(-n);
else return isEven(n - 2);
}
function countChar(string, ch) {
let counted = 0;
for (let i = 0; i < string.length; i++) {
if (string[i] == ch) {
counted += 1;
}
}
return counted;
}
function countBs(string) {
return countChar(string, "B");
}