- 2023-07-18[Typescript] 149 Medium - Triangular number
GivenanumberN,findtheNthtriangularnumber,i.e. 1+2+3+...+N/*_____________YourCodeHere_____________*/exporttypeNumberToArray<Textendsnumber,Rextends1[]=[]>=R["length"]extendsT?R:NumberToArray&
- 2023-07-18[Typescript Challenge] 148 Medium - CartesianProduct
Given2sets(unions),returnitsCartesianproductinasetoftuples,e.g.CartesianProduct<1|2,'a'|'b'>//[1,'a']|[2,'a']|[1,'b']|[2,'b'] Solution:/*____________
- 2023-04-16ts类型体操Concat
/*533-Concat-------byAndreyKrasovsky(@bre30kra69cs)#easy#array###QuestionImplementtheJavaScript`Array.concat`functioninthetypesystem.Atypetakesthetwoarguments.Theoutputshouldbeanewarraythatincludesinputsin
- 2023-04-16ts类型体操 Awaited
/*189-Awaited-------byMaciejSikora(@maciejsikora)#easy#promise#built-in###QuestionIfwehaveatypewhichiswrappedtypelikePromise.Howwecangetatypewhichisinsidethewrappedtype?Forexample:ifwehave`Promise&l
- 2022-12-16前端开发系列089-Node篇之os
title:'前端开发系列089-Node篇之os'tags:-Node系列categories:[]date:2018-10-0723:20:13一、OS模块介绍Node中的OS模块提供了和当前系统相关的一系列实用
- 2022-12-15[Typescript] 138. Hard - SnakeCase
Createa SnakeCase<T> genericthatturnsastringformattedin camelCase intoastringformattedin snake_case.Afewexamples:typeres1=SnakeCase<"he
- 2022-12-11[Typescript] 133. Medium - All
Returnstrueifallelementsofthelistareequaltothesecondparameterpassedin,falseifthereareanymismatches.ForexampletypeTest1=[1,1,1]ty
- 2022-12-07[Typescript] 130. Hard - Replace Union
Givenan unionoftypes and arrayoftypepairs toreplace([[string,number],[Date,null]]),returnanewunionreplacedwiththe typepairs. /*____
- 2022-12-06[Typescript] 129. Hard - Capitalize Nest Object Keys
Capitalizethekeyoftheobject,andifthevalueisanarray,iteratethroughtheobjectsinthearray. /*_____________YourCodeHere_____________*/
- 2022-12-05[Typescript] 127. Hard - Assign
Youhaveatargetobjectandasourcearrayofobjects.Youneedtocopypropertyfromsourcetotarget,ifithasthesamepropertyasthesource,youshould
- 2022-12-04[Typescript] 126. Hard - Two Sum
Givenanarrayofintegers nums andaninteger target,returntrueiftwonumberssuchthattheyaddupto target./*_____________YourCodeHere________
- 2022-12-02[Typescript] 124. Binary to Decimal
Implement BinaryToDecimal<S> whichtakesanexactstringtype S consisting0and1andreturnsanexactnumbertypecorrespondingwith S when S isrega
- 2022-11-30[Typescript] 122. Hard - Mutable Keys
ImplementtheadvancedutiltypeMutableKeys,whichpicksallthemutable(notreadonly)keysintoaunion.Forexample:typeKeys=MutableKeys<{readonlyfo
- 2022-11-28[Typescript] 120. Hard - ObjectFromEntries
Implementthetypeversionof Object.fromEntriesForexample:interfaceModel{name:string;age:number;locations:string[]|null;}typeModelEnt
- 2022-11-27[Typescript] 119. Extreme - Get Readonly Keys
Implementageneric GetReadonlyKeys<T> thatreturnsaunionofthereadonlykeysofanObject.ForexampleinterfaceTodo{readonlytitle:stringreado
- 2022-11-26[Typescript] 117. Hard - ClassPublicKeys
Implementthegeneric ClassPublicKeys<T> whichreturnsallpublickeysofaclass.Forexample:classA{publicstr:stringprotectednum:numberpri
- 2022-11-25[Typescript] 115. Hard - Drop String
Dropthespecifiedcharsfromastring.Forexample:typeButterfly=DropString<'foobar!','fb'>//'ooar!' /*_____________YourCodeHere_____________
- 2022-11-19[Typescript] 111. Hard - String Join
Createatype-safestringjoinutilitywhichcanbeusedlikeso:consthyphenJoiner=join('-')constresult=hyphenJoiner('a','b','c');//='a-b-c'Or
- 2022-11-16[Typescript] 103. Hard - Tuple Filter
Implementatype FilterOut<T,F> thatfiltersoutitemsofthegiventype F fromthetuple T.Forexample,typeFiltered=FilterOut<[1,2,null,3],null
- 2022-11-15[Typescript] 102. Hard - String to Number
Convertastringliteraltoanumber,whichbehaveslike Number.parseInt. /*_____________YourCodeHere_____________*/typeToNumber<Sextendsstring,
- 2022-11-15[Typescript] 101. Hard - Typed Get
The get functioninlodash isaquiteconvenienthelperforaccessingnestedvaluesinJavaScript.However,whenwecometoTypeScript,usingfunctionslike
- 2022-11-12[Typescript] 99. Hard - CamelCase
Implement CamelCase<T> whichconverts snake_case stringto camelCase.ForexampletypecamelCase1=CamelCase<'hello_world_with_types'>//expectedtobe
- 2022-11-12[Typescript] 98. Medium - Append to object
Implementatypethataddsanewfieldtotheinterface.Thetypetakesthethreearguments.Theoutputshouldbeanobjectwiththenewfield.Forexamplety
- 2022-11-11[Typescript] 97. Hard - Capitalize Words
Implement CapitalizeWords<T> whichconvertsthefirstletterof eachwordofastring touppercaseandleavestherestas-is.Forexampletypecapitalized
- 2022-11-11[Typescript] 95. Hard - Required Keys
Implementtheadvancedutiltype RequiredKeys<T>,whichpicksalltherequiredkeysintoaunion.ForexampletypeResult=RequiredKeys<{foo:number;bar?: