I am trying to write a function sortBool(arr) to take an array and return an object with the count for each kind of falsy value found.
For example:
sortBool([1, 0, 10, 2-2, Math.sqrt(-1)]); // should return {0: 2, NaN: 1}
Thus far:
const sortBool = arr => {
index = 0;
let falsyTypes = {};
while (index < arr.length) {
if(eval(arr[index])) {
index++;
}else {
//some code to determine what type of falsy value each element is and then add it to the object
}
}
return falsyTypes;
I am trying to write a functionWhere? What have you tried?