← Back to challenges

Potential Friend?

JavaScriptHardlanguage_fundamentalsarraysvalidation

Instructions

Given two arrays of two people's different interests, return whether both people have at least two things in common or have exact interests. Return true if there's a potential friend!

Examples

isPotentialFriend(
  ["sports", "music", "chess"],
  ["coding", "music", "netflix", "chess"]
) ➞ true

isPotentialFriend(
  ["cycling", "technology", "drawing"],
  ["dancing", "drawing"]
) ➞ false

isPotentialFriend(
  ["history"],
  ["history"]
) ➞ true

Notes

Arrays of interests may have varied lengths.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Wash Your Hands :)