Back to Type Challenges

README

questions/05310-medium-join/README.md

latest1.4 KB
Original Source
<!--info-header-start--><h1>Join </h1><blockquote><p>by Pineapple <a href="https://github.com/Pineapple0919" target="_blank">@Pineapple0919</a></p></blockquote><p><a href="https://tsch.js.org/5310/play" target="_blank"></a> </p><!--info-header-end-->

Implement the type version of Array.join, Join<T, U> takes an Array T, string or number U and returns the Array T with U stitching up.

ts
type Res = Join<["a", "p", "p", "l", "e"], "-">; // expected to be 'a-p-p-l-e'
type Res1 = Join<["Hello", "World"], " ">; // expected to be 'Hello World'
type Res2 = Join<["2", "2", "2"], 1>; // expected to be '21212'
type Res3 = Join<["o"], "u">; // expected to be 'o'
<!--info-footer-start-->

<a href="../../README.md" target="_blank"></a> <a href="https://tsch.js.org/5310/answer" target="_blank"></a> <a href="https://tsch.js.org/5310/solutions" target="_blank"></a> <!--info-footer-end-->