Zip It, If You Can?

Published by Mubashir Hassan in

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

  • Return "Empty 2D Array" 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"])
 ➞ [[]]]

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

Notes

N/A

Watch a quick demo on how Edabit works.