1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- let startfuel = 0;
- let astronauts = 0;
- let altitude = 0;
- let input = require('readline-sync');
-
-
- while (true) {
- startfuel = input.question("Enter starting fuel level: ");
- if (startfuel >= 5_000 && startfuel < 30_000 && !isNaN(startfuel)) {
- break;
- }
- }
-
- while (true) {
- astronauts = input.question("Enter number of astronauts: ");
- astronauts = Number(astronauts);
- if (astronauts > 0 && astronauts <= 7 && !isNaN(astronauts) && Number.isInteger(Number(astronauts))) {
- break;
- }
- }
-
- /*
- // ook mogelijk
- while (true) {
- astronauts = input.question("Enter number of astronauts: ");
- astronauts = Number(astronauts);
- if (astronauts < 0) {
- continue;
- }
- if (astronauts > 7)){
- continue;
- }
- if (isNaN(astronauts)){
- continue;
- }
- if (Number.isInteger(Number(astronauts)){
- continue;
- }
- break;
- }
- */
-
- while (startfuel - 100 * astronauts >= 0) {
- altitude += 50;
- startfuel -= 100 * astronauts;
- }
-
-
- console.log(`fuellevel: ${startfuel}`);
- console.log(`astronauts ${astronauts}`);
|