I have a dilemma with this line of code
let numero = [11,5,7,9,10,12]; console.log(numero.splice(Math.min.aply(null, numero), 1)); console.log(numero);
This line of code should eliminate the number 5 which is the smallest of the array, but it eliminates the 12, I have tried in different ways, but I can't get it to eliminate the 5. I have not found the error thank you all.
You found the number, but then you have tried to remove it by itsef instead of by its index, which is what splice was expecting. Try this:
numero.splice(numero.indexOf(Math.min(...numero)),1)
2.1m questions
2.1m answers
60 comments
57.0k users