Tell us what’s happening:
I dont understand why my .push() makes an error and i need to JSON stringify it. Also it dosnt work and i can’t understand what is wrong.
I used to be able to push things into an array easily ( i think).
Why is there “TypeError: String is not a function”
Your code so far
function bouncer(arr){
let i = 0;
let newArray = [];
for(let arg of arr){
if(arg == false || arg == null || arg == "" || arg == undefined || arg.isNaN){
console.log(arg + " -> got shot outta space")
}
else{
newArray.push(arg);
i++;
}
}
return newArray;
}
console.log(JSON.stringify(bouncer(["a", "b", "c", 12, false, null, 0, NaN, undefined, "" ])));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:147.0) Gecko/20100101 Firefox/147.0
Challenge Information:
Implement a Falsy Remover - Implement a Falsy Remover