Back to Type Challenges

README

questions/00018-easy-tuple-length/README.md

latest1.8 KB
Original Source
<!--info-header-start--><h1>Length of Tuple </h1><blockquote><p>by sinoon <a href="https://github.com/sinoon" target="_blank">@sinoon</a></p></blockquote><p><a href="https://tsch.js.org/18/play" target="_blank"></a> &nbsp;&nbsp;&nbsp;<a href="./README.zh-CN.md" target="_blank"></a> <a href="./README.ja.md" target="_blank"></a> <a href="./README.ko.md" target="_blank"></a> </p><!--info-header-end-->

For given a tuple, you need create a generic Length, pick the length of the tuple

For example:

ts
type tesla = ['tesla', 'model 3', 'model X', 'model Y']
type spaceX = ['FALCON 9', 'FALCON HEAVY', 'DRAGON', 'STARSHIP', 'HUMAN SPACEFLIGHT']

type teslaLength = Length<tesla>  // expected 4
type spaceXLength = Length<spaceX> // expected 5
<!--info-footer-start-->

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