Answers for "javascript given range how to make sure array contains all values?"

0

javascript given range how to make sure array contains all values?

// JavaScript - Given a range, how to check array contains all values?"
// Use of .every() & .includes() combined.
// Returns true or false.

let range = [1,2,3,4,5,6,7,8,9] // Use this array to repeatedly checking against, does not change.
let myArray = [8,6,7,5,3,1,2,4,9] // Array that fluctuates and checking for validity.

let checker = (myArray, range) => ( 
  range.every(value => (
  	myArray.includes(value)) 
  );
)

console.log(checker(myArray, range)); // true.
Posted by: Guest on April-09-2020

Code answers related to "javascript given range how to make sure array contains all values?"

Code answers related to "Javascript"

Browse Popular Code Answers by Language