Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Challenge (snail game) | Loops
Introductie tot TypeScript

bookChallenge (snail game)

Task

Congratulations, you've been hired as a developer for the indie game 'Snail Simulator.' Your goal is to design the snail's movement logic. Snails are not very fast, and each snail has its own stamina. You need to calculate the maximum distance the snail will travel if it spends 2% of its stamina for every meter it covers. Use a while loop to solve this problem and then display the result on the screen. Good luck!

123456789
let stamina: number = 100; let distance: number = 0; const staminaPerMeter: number = 2; while (stamina > ___) { stamina = ___ - ___; ___++; } console.log(`The snail got tired; it ran ${___} meters. This is a new record, congratulations!`)
copy

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 4. Hoofdstuk 4

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

Suggested prompts:

What happens if the snail's stamina is not a multiple of the stamina used per meter?

Can I change the initial stamina or staminaPerMeter values to test different scenarios?

Can you explain how the while loop works in this context?

Awesome!

Completion rate improved to 2.94

bookChallenge (snail game)

Veeg om het menu te tonen

Task

Congratulations, you've been hired as a developer for the indie game 'Snail Simulator.' Your goal is to design the snail's movement logic. Snails are not very fast, and each snail has its own stamina. You need to calculate the maximum distance the snail will travel if it spends 2% of its stamina for every meter it covers. Use a while loop to solve this problem and then display the result on the screen. Good luck!

123456789
let stamina: number = 100; let distance: number = 0; const staminaPerMeter: number = 2; while (stamina > ___) { stamina = ___ - ___; ___++; } console.log(`The snail got tired; it ran ${___} meters. This is a new record, congratulations!`)
copy

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 4. Hoofdstuk 4
some-alt