I want to return an array
function estanParaTrasplantar(alturasDePlantas) {
let plantasMayoresA20Cm = [];
for (let planta of alturasDePlantas) {
if (planta.altura > 20) {
agregar(plantasMayoresA20Cm, planta);
}
}
return plantasMayoresA20Cm;
}
When I run [21, 29, 5, 20] I get this output
[] deepEqual [ 21, 29 ]
How can I return the array without the deepEqual stuff? Thanks
>Solution :
Instead of using agregar, filter out numbers greater than 20
function estanParaTrasplantar(alturasDePlantas) {
return alturasDePlantas.filter(x => x > 20)
}
Note
for of will pick some weird array prototype values hence the weird things you’re getting.