这是indexloc提供的服务,不要输入任何密码
Skip to content

3060 - Unshift (🎥 Video Explanation and Solution) #21541

@dimitropoulos

Description

@dimitropoulos

3060 - Unshift

Silence before the storm. This challenge is nearly identical to the previous (Push), but after this the heat gets turned up quite considerably. Get ready! Enjoy your day off with this challenge.

🎥 Video Explanation

Release Date: 2023-01-13 19:00 UTC

Unshift

🔢 Code

import type { Equal, Expect } from './test-utils'

type A1 = Unshift<[], 1>;
type B1 = [1];
type C1 = Expect<Equal<A1, B1>>;

type A2 = Unshift<[1, 2], 0>;
type B2 = [0, 1, 2];
type C2 = Expect<Equal<A2, B2>>;

type A3 = Unshift<['1', 2, '3'], boolean>;
type B3 = [boolean, '1', 2, '3'];
type C3 = Expect<Equal<A3, B3>>;

// ============= Your Code Here =============
type Unshift<T extends unknown [], U> = [U, ...T];

➕ More Solutions

For more video solutions to other challenges: see the umbrella list! #21338

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions