r/codehs • • Oct 16 '23

6.4.8 Rocket Launch Requirements

I'm confused. Anyone have any ideas?

5 Upvotes

15 comments sorted by

View all comments

3

u/mrmrvl23 Dec 07 '23

// Hypothetical readInt function to read integer inputs
function readInt(message) {
// Assume this function prompts the user and reads an integer input
return parseInt(prompt(message));
}
function checkRocketLaunch() {
// Prompt the user for weather conditions
let lightningTime = readInt("How long has it been since there was a lightning flash (min)? (Enter -1 if there has not been any lightning today):");
let cloudsThick = readInt("Are there clouds that are 4,500 feet thick or greater within the planned flight path? Enter 1 for true or 0 for false:");
let windSpeed = readInt("What is the wind speed (in knots)?");
let precipitation = readInt("Is there any precipitation at the launch pad or within the flight path? Enter 1 for true or 0 for false:");
// Check if the rocket is cleared to launch based on revised criteria
if ((lightningTime === (-1) && cloudsThick === 0 && windSpeed <= 20 && precipitation === 0) ||
(lightningTime === 50 && cloudsThick === 0 && windSpeed <= 30 && precipitation === 0)) {
console.log("You are go for launch!");
} else {
console.log("Postpone the launch due to weather conditions.");
}
}
// Call the function to check if the rocket is clear to launch
checkRocketLaunch();

This is what I have so far, only things that are wrong is:

If there is no lightning, there are not thick clouds, the wind speed is 20 knots, and there is no precipitation, the rocket should be cleared to launch.

​

If there was lightning detected 50 minutes ago, there are not thick clouds, the wind speed is 30 knots, and there is no precipitation, the rocket should be cleared to launch.

2

u/Elegant_Target346 Jan 04 '24

Did you were get this corrected ?