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
arrand 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
rtnArrcontaining the remaining elements.
文件大小:371B
评论区