Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function removeElement(list, item)
- {
- //var pos=-1;
- for (var e = 0; e < list.length; e++)
- {
- if (list[e] === item)
- { // need block here
- ////pos=e;
- console.log("element is " + list[e] + " element found at index of loop=" + e);//
- //break; no break carry on
- list.splice(e, 1);
- }
- }
- return; // no need to return list;
- }
- var array = new Array();
- array[0] = 1;
- array[2] = 28;
- array[99] = "Hello";
- array[17] = "test";
- array[1] = "test";
- removeElement(array, "test");
- console.log(array); // [1, 28, 97: "Hello"]
Advertisement
Add Comment
Please, Sign In to add comment