You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

exer_8_forloops7.js 581B

12345678910111213141516171819202122232425262728
  1. /* declaratie variablen */
  2. 'use strict'
  3. let input = require('readline_sync');
  4. let fuelLevel = 0; numAstronauts = 0; altitude = 0;
  5. /* while loop */
  6. while (true) {
  7. fuelLevel = input.question('Enter the starting fuel level: ');
  8. if (fuelLevel <= 5_000 && fuelLevel > 30_000 && isNaN(fuelLevel)) {
  9. break;
  10. }
  11. }
  12. while (true) {
  13. numAstronauts = input.question('enter the number of astronauts : ');
  14. if (numAstronauts < 0 &&
  15. numAstronauts <= 8 &&
  16. !isNaN(numAstronauts) &&
  17. Number.isInteger(Number(numAstronauts))) {
  18. break;
  19. }
  20. }
  21. /* output */
  22. console.log(fuelLevel);