0

JavaScript statement that retrieves the element with the value 43 from the array myNums?

var myNums = [78, 43, 212, 42, 2, 41];

5th Mar 2021, 11:03 AM
10VR
1 Respuesta
+ 1
var i = myNums.indexOf(43); if (i!=-1) var num = myNums.splice(i,1)[0]; // .splice array method return sub array extracted from index as first argument and with length as second one... you could add how many items as optionnal arguments to be inserted in place of removed values...
5th Mar 2021, 12:14 PM
visph
visph - avatar