Exercise · Arrays · lesson 12 of 13
Exercise: without a value
Write a function function without(nums, value) that returns a new array of the elements of nums that are not equal to value, in their original order. The function does not change the array nums itself, and the result is always a new array, even when there is nothing to remove.
without([1, 2, 3, 2], 2)→[1, 3]without([1, 2, 3], 5)→[1, 2, 3]without([4, 4], 4)→[]
Constraints: nums holds from 0 to 1000 integers, and value is an integer; it may occur in the array several times or not at all; after the call, nums holds the same elements in the same order.
Do not add extra imports unless the task says so explicitly.
Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.