Skip to content

Latest commit

 

History

History
9 lines (8 loc) · 310 Bytes

check_if_two_arrays_have_the_same_values.md

File metadata and controls

9 lines (8 loc) · 310 Bytes

Check if two arrays have the same values

This is only valid if the arrays contain primitive values.

const checkIfArraysHaveSameValues = (array1, array2) => {
  const uniques = [...new Set(array1.concat(array2))];
  return uniques.length === array1.length // or uniques.length === array2.length;
}