Push
#
introductionImplement the generic version of Array.push
For example
typescript
type Result = Push<[1, 2], '3'>; // [1, 2, '3']
View on GitHubtypescript
type Result = Push<[1, 2], '3'>; // [1, 2, '3']
#
start pointtsTry
/* _____________ Your Code Here _____________ */typePush <T ,U > = any;Â/* _____________ Test Cases _____________ */Âtypecases = [Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <Push <[], 1>, [1]>>,Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <Push <[1, 2], '3'>, [1, 2, '3']>>,Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <Push <['1', 2, '3'], boolean>, ['1', 2, '3', boolean]>>];
take the challengetsTry
/* _____________ Your Code Here _____________ */typePush <T ,U > = any;Â/* _____________ Test Cases _____________ */Âtypecases = [Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <Push <[], 1>, [1]>>,Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <Push <[1, 2], '3'>, [1, 2, '3']>>,Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <Push <['1', 2, '3'], boolean>, ['1', 2, '3', boolean]>>];