← Back to challenges

Zip It, If You Can?

JavaScriptHardarraysformattingsorting

Instructions

Given an array of women and an array of men, either:

  • Return "sizes don't match" if the two arrays have different sizes.
  • If the sizes match, return an array of pairs, with the first woman paired with the first man, second woman paired with the second man, etc.

Examples

zipIt(["Elise", "Mary"], ["John", "Rick"])
 ➞ [["Elise", "John"], ["Mary", "Rick"]]

zipIt(["Ana", "Amy", "Lisa"], ["Bob", "Josh"])
 ➞ "sizes don't match"

zipIt(["Ana", "Amy", "Lisa"], ["Bob", "Josh", "Tim"])
 ➞ [["Ana", "Bob"], ["Amy", "Josh"],["Lisa", "Tim"]]

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Find the Mean of All Digits