In this question, the candidate needs to implement a function
customIncludes that mimics the behaviour of
includes() method determines whether an array includes a certain value among its entries, returning
false as appropriate.
const array = [5, 12, 8, 130, 44]; const found = array.customIncludes(5); // prints true console.print(found);
customIncludes takes two parameters
The value to search for.
The position in this array at which to begin searching for searchElement.
The first element to be searched is found at
fromIndex for positive values of
fromIndex, or at
arr.length + fromIndex for negative values of
Defaults to 0.
A boolean value which is true if the value searchElement is found within the array (or the part of the array indicated by the index fromIndex, if specified).
array.customIncludes(searchElement); array.customIncludes(searchElement, fromIndex);
Start the timer, complete your solution, and test it against the test cases provided by the platform. Ideally, you should finish this question within 30 mins. Share your solution with us -- https://twitter.com/devtoolstech