Back to Type Challenges

README

questions/00108-medium-trim/README.md

latest2.2 KB
Original Source
<!--info-header-start--><h1>Trim </h1><blockquote><p>by Anthony Fu <a href="https://github.com/antfu" target="_blank">@antfu</a></p></blockquote><p><a href="https://tsch.js.org/108/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-->

Implement Trim<T> which takes an exact string type and returns a new string with the whitespace from both ends removed.

For example

ts
type trimmed = Trim<'  Hello World  '> // expected to be 'Hello World'
<!--info-footer-start-->

<a href="../../README.md" target="_blank"></a> <a href="https://tsch.js.org/108/answer" target="_blank"></a> <a href="https://tsch.js.org/108/solutions" target="_blank"></a> <hr><h3>Related Challenges</h3><a href="https://github.com/type-challenges/type-challenges/blob/main/questions/00106-medium-trimleft/README.md" target="_blank"></a> <a href="https://github.com/type-challenges/type-challenges/blob/main/questions/04803-medium-trim-right/README.md" target="_blank"></a> <!--info-footer-end-->