Editing JavaScript/Notes/Array
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 88: | Line 88: | ||
== Assignment 1 Write a function that removes an element from an array. == | == Assignment 1 Write a function that removes an element from an array. == | ||
Write a function that that takes an array and a specified element, and returns | Write a function that that takes an array and a specified element, and returns a new array, minus the first occurence of the element from the array. | ||
Given: | Given: | ||
Line 99: | Line 99: | ||
<!-- | <!-- | ||
function removeElement(a, x) { | function removeElement(a, x) { | ||
var i = a.indexOf(x); | var i = a.indexOf(x); |