generated from LaunchCodeEducation/Launch-Checklist
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathscriptHelper.js
75 lines (63 loc) · 2.64 KB
/
scriptHelper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Write your helper functions here!
require('isomorphic-fetch');
function addDestinationInfo(document, name, diameter, star, distance, moons, imageUrl) {
// get the missionTarget div
// set the inner HTML to this
// fill in the information that is passed in
// Here is the HTML formatting for our mission target div.
/*
`
<h2>Mission Destination</h2>
<ol>
<li>Name: ${name}</li>
<li>Diameter: </li>
<li>Star: ${star}</li>
<li>Distance from Earth: </li>
<li>Number of Moons: </li>
</ol>
<img src="">
`
*/
}
function validateInput(testInput) {
//check if the test Input is empty
// if it is, return 'Empty'
// check if it's not a number isNaN
// return 'Not a Number'
// else
// return 'Is a Number'
}
function formSubmission(document, list, pilotValue, copilotValue, fuelLevelValue, cargoLevelValue) {
// check if any of the values are empty
// if (validateInput(pilotValue) === 'Empty' || validateInput(copilotValue) === 'Empty')
// alert user that they need to fill out all the fields alert('message')
// check if fuelLevelValue and cargoLevelValue are not numbers
// alert the user that must enter valid input
// set the list.style.visibility = 'visible'
// get the pilot status, update the inner HTML to say `Pilot ${pilotValue} is ready for launch`
// get the copilot status, update the inner HTML to say `CoPilot ${copilotValue} is ready for launch`
// check if the fuel level is less 10,000
// change launchStatus to "Shuttle not ready for launch", and color to red
// change the fuelStatus to "Fuel level too low for launch"
// check if the cargo level is more than 10,000
// change launchStatus to "Shuttle not ready for launch", and color to red
// change the cargoStatus to "Cargo level too high for launch"
// if both fuel and cargo are good
// change the launchStatus to "Shuttle is Ready for Launch" and color to green
}
async function myFetch() {
let planetsReturned;
planetsReturned = await fetch('https://handlers.education.launchcode.org/static/planets.json').then(function (response) {
// get the json from the response
});
return planetsReturned;
}
function pickPlanet(planets) {
// randomly pick a planet from the array
// Math random for index
}
module.exports.addDestinationInfo = addDestinationInfo;
module.exports.validateInput = validateInput;
module.exports.formSubmission = formSubmission;
module.exports.pickPlanet = pickPlanet;
module.exports.myFetch = myFetch;