generated from LaunchCodeEducation/Launch-Checklist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscriptHelper.js
84 lines (61 loc) · 2.49 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
76
77
78
79
80
81
82
83
84
// Write your helper functions here!
require('isomorphic-fetch');
function addDestinationInfo(document, name, diameter, star, distance, moons, imageUrl) {
// Here is the HTML formatting for our mission target div.
/*
<h2>Mission Destination</h2>
<ol>
<li>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) {
// if (pilotName.value === "" || copilotName.value === "") {
// alert("All fields are required!");
// event.preventDefault();
// }
// if (!isNaN(pilotName.value) || !isNaN(copilotName.value)) {
// alert("Please do not enter number for Pilot name and Co-pilot name");
// event.preventDefault();
// }
// if (isNaN(fuelLevel.value) || isNaN(cargoMass.value)) {
// window.alert("Please enter number for Fuel Level and Cargo Mass");
// event.preventDefault();
// }
// if (pilotName.value !== "" && isNaN(pilotName.value) && isNaN(copilotName.value) && copilotName.value !== "" && !isNaN(fuelLevel.value) && !isNaN(cargoMass.value)) {
// window.alert("LAUNCCHHHHHHHHHHHHHH");
// event.preventDefault();
// }
// }
function formSubmission(document, list, pilot, copilot, fuelLevel, cargoLevel) {
}
async function myFetch() {
let planetsReturned;
planetsReturned = await fetch("https://handlers.education.launchcode.org/static/planets.json").then(function (response) {
response.json().then(function (json) {
for (let i = 0; i < json.length; i++)
missionTarget.innerHTML = `
<h2>Mission Destination</h2>
<ol>
<li>Name: ${json[i].name}</li>
<li>Diameter: ${json[i].diameter}</li>
<li>Star: ${json[i].star}</li>
<li>Distance: ${json[i].distance}</li>
<li>Number of Moons: ${json[i].moons}</li>
</ol>
<img src="${json[i].image}">`
});
return planetsReturned;
})
}
console.log(pickPlanet("diz"))
module.exports.addDestinationInfo = addDestinationInfo;
module.exports.validateInput = validateInput;
module.exports.formSubmission = formSubmission;
module.exports.pickPlanet = pickPlanet;
module.exports.myFetch = myFetch;