I have variables assigned to values as:
let x = 5;
let y = 17;
let z = 0;
const newArr = [];
Here I am trying to push the x, y, x values if they aren't falsy values
I am doing as:
if(x){
newArr.push(x);
}
if(y){
newArr.push(y);
}
if(z){
newArr.push(z);
}
May I know more efficient way to do this, TIA