GitHub - LearningTypeScript/projects: Hands-on real world projects that will help you exercise your knowledge of TypeScript.
Hands-on real world projects that will help you exercise your knowledge of TypeScript. - GitHub - LearningTypeScript/projects: Hands-on real world projects that will help you exercise your knowledg...
github.com
수정해야 할 두 번째이자 마지막 코드 영역은 광대 할당 플래너입니다.
나는 이것을 사용하여 어떤 광대가 어떤 손님과 파티를 할 것인지 출력합니다.
아, 그리고 그들은 코멘트에 몇 가지 불안한 광대 말장난을 소개했습니다.
그 말장난 때문에 제가 직접 코드를 고칠 수 없습니다.
광대는 다시 몇 가지 사항을 변경했지만 잘못된 타입 어노테이션과
변수에 대한 잘못된 값에 지나지 않습니다.
TypeScript가 불만이 없도록 파일을 수정해 주시겠습니까?
## 파일
index.ts: 여기에서 코드 수정
solution.ts: 솔루션 코드
// Note: I'm planning on inviting 20 guests in total.
// Some clowns can only handle a certain number of guests.
let guestCount = 20;
let clownsCount = 0;
let krustyAvailability = true;
let ronaldAvailability = true;
let pennywiseAvailability = true;
let matchingsDescription = "";
let lastClown : string;
do {
clownsCount += 1;
// Krusty says: I had a one-man show on Broadway...
// That's who showed up, one man!
if (krustyAvailability) {
guestCount -= 10;
krustyAvailability = false;
matchingsDescription += "Krusty will handle the first ten guests.\n";
lastClown = "Krusty";
continue;
}
// Ronald says: McDonald's donated a large set of computers to a school...
// They were all Big Macs!
if (ronaldAvailability) {
guestCount -= 5;
ronaldAvailability = false;
matchingsDescription += "Ronald will handle the next five guests.\n";
lastClown = "Ronald";
continue;
}
// Pennywise asks: what's a sewer's favorite data type?
// Pennywise answers: Floats!
if (pennywiseAvailability) {
pennywiseAvailability = false;
matchingsDescription += "Pennywise w̺̞̠i̢͇͙l͇̞l͇͍̘ c͓͕̝o̡̠̞n̼̝s̡̞͎u͉̝͔m͚̪̞e̢͚̝ y̴̡̡͕͌̿́ó̸̢͇͚̾̕u̸̡̡͎͒͛r̸͕͓͖̈́͆͒ s̵̺̘̪͒͆̓o̵̡͚̟̽͆̚u̵̠͖̓͐͝l̸͓̘͇̐̓̚s̸̺͎̽̈́͆.";
lastClown = "Pennywise";
continue;
}
throw new Error(`Oh no! We're out of clowns!`);
} while (guestCount > 0);
if (clownsCount > 2) {
console.log("We've got a lot of clowns coming!");
}
if (matchingsDescription.length) {
console.log(`There will be ${clownsCount} clowns!\n`);
console.log(matchingsDescription);
console.log(`The last clown is: ${lastClown.toUpperCase()}!`);
} else {
console.log("Nobody gets a clown. Terrible party. Goodbye.");
}
export {};
첫번째 문제와 마찬가지로 간단한 타입 수정 문제
728x90
'Typescript > 러닝 타입스크립트 연습문제' 카테고리의 다른 글
(3장) Primitive Cooking - 2. Recipes (0) | 2023.04.06 |
---|---|
(3장) Primitive Cooking - 1. Ingredients (0) | 2023.04.06 |
(2장) System of a Clown - 1. Clowning Around (0) | 2023.04.06 |
(1장) The Typeinator - 3. Callbacks to Async Await (0) | 2023.04.05 |
(1장) The Typeinator - 2. Prototypes to Classes (0) | 2023.04.05 |