I'm new to JavaScript and not sure why my code isn't working. I'm trying to return true if there are an equal amount of x's and o's, and return false if there are not. My code works for all inputs except "x" and "o". Any help is appreciated!
My code:
function ExOh(str) {
var x = str.match(/[^x$]/gi);
var o = str.match(/[^o$]/gi);
if (x.length == o.length) {
return true;
}
else {
return false;
}
}