Remove Element from Array and Return Remaining Elements
Function: Remove specified element from array
Parameters:
- element: the specified element to be removed
- arr: the array from which the element will be removed
Return: rtnArr
, the array with the specified element removed.
Steps
- Iterate through the array
arr
and compare each element with the specifiedelement
. - If the current element is not equal to
element
, append it to a new arrayrtnArr
. - Return the newly created
rtnArr
containing the remaining elements.
371B
文件大小:
评论区