Is One Array a Subset of Another?

Published by Matt in

Create a function that returns true if the first array is a subset of the second. Return false otherwise.

Examples

isSubset([3, 2, 5], [5, 3, 7, 9, 2]) ➞ true

isSubset([8, 9], [7, 1, 9, 8, 4, 5, 6]) ➞ true

isSubset([1, 2], [3, 5, 9, 1]) ➞ false

Notes

Both arrays will contain only unique values.

Watch a quick demo on how Edabit works.