javascript given range how to make sure array contains all values 3f

Solutions on MaxInterview for javascript given range how to make sure array contains all values 3f by the best coders in the world

showing results for - "javascript given range how to make sure array contains all values 3f"
Jacobo
17 May 2019
1// JavaScript - Given a range, how to check array contains all values?"
2// Use of .every() & .includes() combined.
3// Returns true or false.
4
5let range = [1,2,3,4,5,6,7,8,9] // Use this array to repeatedly checking against, does not change.
6let myArray = [8,6,7,5,3,1,2,4,9] // Array that fluctuates and checking for validity.
7
8let checker = (myArray, range) => ( 
9  range.every(value => (
10  	myArray.includes(value)) 
11  );
12)
13
14console.log(checker(myArray, range)); // true.