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.
|
|
|
## Index Of
|
|
|
|
|
|
|
|
### Instructions
|
|
|
|
|
|
|
|
Create 3 functions:
|
|
|
|
- `indexOf` that return the index of the first occurence of a value
|
|
|
|
- `lastIndexOf` that return the index of the last occurence of a value
|
|
|
|
- `includes` that return true if the value was found in the array
|
|
|
|
|
|
|
|
> If a value is not found, the returned index is -1
|
|
|
|
|
|
|
|
> functions should have array element as first argument
|
|
|
|
> `indexOf` and `lastIndexOf` takes an additionnal `fromIndex` argument
|
|
|
|
> that allow you to begin searching from a specific index.
|
|
|
|
|
|
|
|
|
|
|
|
### Notions
|
|
|
|
|
|
|
|
- [https://devdocs.io/javascript/global_objects/array/indexof](https://devdocs.io/javascript/global_objects/array/indexof)
|
|
|
|
- [https://devdocs.io/javascript/global_objects/array/lastindexof](https://devdocs.io/javascript/global_objects/array/lastindexof)
|
|
|
|
- [https://devdocs.io/javascript/global_objects/array/includes](https://devdocs.io/javascript/global_objects/array/includes)
|
|
|
|
|
|
|
|
|
|
|
|
### Code provided
|
|
|
|
|
|
|
|
> all code provided will be added to your solution and doesn't need to be submited.
|
|
|
|
|
|
|
|
```js
|
|
|
|
Array.prototype.indexOf = undefined
|
|
|
|
Array.prototype.lastIndexOf = undefined
|
|
|
|
Array.prototype.includes = undefined
|
|
|
|
```
|