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.

32 lines
1.3 KiB

## Index Of
### Instructions
Create 3 functions:
2 years ago
- `indexOf` which returns the index of the first occurrence of a value and takes as arguments an array to be searched, the value to be matched, and optionally the index from where to start searching from.
- `lastIndexOf` which works just like the previous function but returns the index of the last occurrence of a value
- `includes` which returns true if the value was found in the array
> If a value is not found, the returned index is -1
> functions should have an array element as first argument,
> both `indexOf` and `lastIndexOf` take an additional `fromIndex` argument
2 years ago
> that allows you to begin searching from a specific index and it will work exactly like in the original methods.
### Notions
- [devdocs.io/javascript/global_objects/array/indexof](https://devdocs.io/javascript/global_objects/array/indexof)
- [devdocs.io/javascript/global_objects/array/lastindexof](https://devdocs.io/javascript/global_objects/array/lastindexof)
- [devdocs.io/javascript/global_objects/array/includes](https://devdocs.io/javascript/global_objects/array/includes)
### Code provided
2 years ago
> all code provided will be added to your solution and doesn't need to be submitted.
```js
Array.prototype.indexOf = undefined
Array.prototype.lastIndexOf = undefined
Array.prototype.includes = undefined
```