JSFiddle - React, Tailwind, and code Playground
by shapeshifta
JavaScript
var minimum = function(a, b) {
return (a >= b) ? b : a;
}
//console.log(minimum(3,1));
var isEven = function(number) {
var test = function(num) {
if (num === 0) {
return true;
} else if (num === 1) {
return false;
} else {
return test(num - 2);
}
};
return test(number);
}
//console.log(isEven(0), isEven(75), isEven(11), isEven(50));
var countChar = function(s, f) {
var test = function(string, find) {
var count = 0,
countChar = 0;
while (count <= string.length -1) {
if (string.charAt(count) === find) {
countChar++;
}
count++
}
return countChar;
}
return test(s, f);
};
console.log(countChar('bBBssaerfwefgBB', 'x'), countChar('bBBssaerfwefgBB', 's'));