#4471Medium

Zip

In This Challenge, You should implement a type `Zip<T, U>`, T and U must be `Tuple` Learn tuple manipulation in this medium-level challenge on TypeScriptPro.

In this medium-level challenge, you'll implement a Zip type that pairs up corresponding elements from two tuples into a tuple of pairs, stopping at the length of the shorter tuple.

Challenge Instructions: Zip

Medium

In This Challenge, You should implement a type Zip<T, U>, T and U must be Tuple

type exp = Zip<[1, 2], [true, false]> // expected to be [[1, true], [2, false]]

Change the following code to make the test cases pass (no type check errors).

Loading...

Detailed Explanation

type Zip<T extends any[], U extends any[]> =
  T extends [infer TFirst, ...infer TRest]
    ? U extends [infer UFirst, ...infer URest]
      ? [[TFirst, UFirst], ...Zip<TRest, URest>]
      : []
    : [];

How it works:

This challenge helps you understand parallel tuple traversal and recursive type pairing, and how to apply these concepts in real-world scenarios.

This challenge is originally from here.

Share this challenge

Join early, learn faster.

Be the first to access the course, unlock exclusive launch bonuses, and get special early-bird pricing before anyone else.

No spam, unsubscribe at any time. We respect your privacy.

Limited Availability

Only 27 Spots left

Early Access

Get 1 month early access

>75% Off

Pre-Launch discount