I cannot figure this one out.
string s has the value of "john".
my function is supposed to return whether the number of occurrences of mike and john in s are the same.
It correctly prints the count of mike to be 0. It correctly prints the count of john to be 1.
And yet, after checking for equality between the two, it returns true! why?
function solve(s) {
// Write your code here
var countm = (s.match(/mike/g) || []).length;
var countj = (s.match(/john/g) || []).length;
console.log(countm);
console.log(countj);
if (countm == countj) {
return Boolean("true");
} else {
return Boolean("false");
}
}
console.log(solve('john'));