You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
1.1 KiB

## Index Of
### Instructions
Create 3 functions which accept an array to be searched, and a value to be matched.
- `indexOf`: which returns the index of the first occurrence. It also accepts an **optional** index from where the search should begin. If the value was not found, `-1` is returned.
- `lastIndexOf`: which works just like your `indexOf` function, but returns the index of the last occurrence.
- `includes`: which returns `true` if the value was found in the array, and `false` otherwise.
> Of course you **must not** use any of `Array.indexOf()`, `Array.lastIndexOf()` or `Array.includes()`.
### Notions
- [Array.indexOf](https://devdocs.io/javascript/global_objects/array/indexof)
- [Array.lastIndexOf](https://devdocs.io/javascript/global_objects/array/lastindexof)
- [Array.includes](https://devdocs.io/javascript/global_objects/array/includes)
### Code provided
> The provided code will be added to your solution, and does not need to be submitted.
```js
Array.prototype.indexOf = undefined
Array.prototype.lastIndexOf = undefined
Array.prototype.includes = undefined
```