typescript-exercises(十)
如果你不尊敬你的父母,那你的孩子也将不会尊敬你。——佚名 题目: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146/*Intro: We have asynchronous functions now, advanced technology. This makes us a tech startup officially now. But one of t...
typescript-exercises(九)
如果你要宽容别人的过错,就要把眼光放到自己身上。——佚名 题目: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170/*Intro: PowerUsers idea was bad. Once those users got ...
typescript-exercises(八)
再也无需前思后想,一切岂非已然过往。——《且听风吟》 题目: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293/*Intro: Project grew and we ended up in a situation with some users starting to have more influence. Therefore, we decided to create a new person type called PowerUser which is supposed to combine everything User and Admin have.Exercise: Define type PowerUser which sh...
typescript-exercises(七)
若我会见到你,事隔经年。我如何和你招呼,以眼泪,以沉默。——《春逝》 题目: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125/*Intro: Filtering was completely removed from the project. It turned out that this feature was just not needed for the end-user and we spent a lot of time just because our offi...
typescript-exercises(六)
请热爱劳动,即使不是靠它吃饭,也可以为了身体的缘故而爱它,它可以增进身心健康,免除怠惰之累。——潘恩 题目: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384/*Intro: Filtering requirements have grown. We need to be able to filter any kind of Persons.Exercise: Fix typing for the filterPersons so that it can filter users and return User[] when personType='user' and return Admin[] when personType='admin'...
typescript-exercises(五)
一次冒险,胜过一千个安逸的日子。——保罗·科埃略《韦罗妮卡决定去死》 题目: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108/*Intro: Time to filter the data! In order to be flexible we filter users using a number of criteria and return only those matching all of the criteria. We don't need Admins yet, we only filter Users.Exercise: Without du...
typescript-exercises(四)
取悦于人并不困难,问题只是你是否能够了解别人的喜恶心理。——卡耐基 题目: 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970/*Intro: As we introduced "type" to both User and Admin it's now easier to distinguish between them. Once object type checking logic was extracted into separate functions isUser and isAdmin - logPerson function got new type errors.Exercise: Figure out how to help TypeScript understand types i...
typescript-exercises(三)
青年人的教育是国家的基石。——富兰克林 题面: 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970/*Intro: Since we already have some of the additional information about our users, it's a good idea to output it in a nice way.Exercise: Fix type errors in logPerson function. logPerson function should accept both User and Admin and should output relevant information according to the input: occupation for User an...
typescript-exercises(二)
亲善产生幸福,文明带来和谐。——雨果 题目: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566/*Intro: All 2 users liked the idea of the community. We should go forward and introduce some order. We are in Germany after all. Let's add a couple of admins. Initially, we only had users in the in-memory database. After introducing Admins, we need to fix the types so that everything works well together.Exercise: Type &q...
typescript-exercises(一)
你要克服的是你的虚荣心、炫耀欲,你要对付的是你时刻想要出风头的小聪明。——毛姆 题目: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104/*Welcome to: ................................................................ . . . #################### #################### E . . ####################...
