-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
35 lines (30 loc) · 1.5 KB
/
script.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
// Write your JavaScript code here!
window.addEventListener("load", function() {
let listedPlanets;
// Set listedPlanetsResponse equal to the value returned by calling myFetch()
let listedPlanetsResponse = myFetch();
listedPlanetsResponse.then(function (result) {
listedPlanets = result;
console.log(listedPlanets);
}).then(function () {
console.log(listedPlanets);
// Below this comment call the appropriate helper functions to pick a planet fom the list of planets and add that information to your destination.
let selectedPlanet = pickPlanet(listedPlanets);
addDestinationInfo(document, selectedPlanet.name, selectedPlanet.diameter, selectedPlanet.star, selectedPlanet.distance, selectedPlanet.moons, selectedPlanet.image);
})
let form = document.querySelector("form");
form.addEventListener("submit", function(event){
event.preventDefault();
let pilotName = document.querySelector("input[name=pilotName]");
let pilot = pilotName.value;
let copilotName = document.querySelector("input[name=copilotName]");
let copilot = copilotName.value;
let fuelInput = document.querySelector("input[name=fuelLevel]");
let fuelLevel = fuelInput.value;
let cargoInput = document.querySelector("input[name=cargoMass]");
let cargoLevel = cargoInput.value;
let list = document.getElementById("faultyItems");
list.style.visibility = "visible";
formSubmission(document, list, pilot, copilot, fuelLevel, cargoLevel);
})
});