Update snippet descriptions

This commit is contained in:
Isabelle Viktoria Maciohsek
2020-10-20 23:02:01 +03:00
parent 52880f08ee
commit caa67e2a49
63 changed files with 175 additions and 126 deletions

View File

@ -3,10 +3,11 @@ title: isContainedIn
tags: array,intermediate
---
Returns `true` if the elements of the first array are contained in the second one regardless of order, `false` otherwise.
Checks if the elements of the first array are contained in the second one regardless of order.
- Use a `for...of` loop over a `Set` created from the first array.
- Use `Array.prototype.some()` to check if all distinct values are contained in the second array, use `Array.prototype.filter()` to compare the number of occurrences of each distinct value in both arrays.
- Use `Array.prototype.some()` to check if all distinct values are contained in the second array.
- Use `Array.prototype.filter()` to compare the number of occurrences of each distinct value in both arrays.
- Return `false` if the count of any element is greater in the first array than the second one, `true` otherwise.
```js