How Can I Skip A Specific Index In An Array In A For Loop Javascript
Suppose I had a function that is pulling in values from somewhere and storing those values into an array. function getSport(ply) { some code here... //function gets values tha
Solution 1:
I want to skip index 0. How do I do that? Further I want to replace index 0 with something else.
Just start the loop from 1
instead of 0
sportsArr[0] = "Something else"; // set the first element to something elsefor(var i = 1; i < sportsArr.length; i++){
// do something
}
Post a Comment for "How Can I Skip A Specific Index In An Array In A For Loop Javascript"