-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
45 lines (36 loc) · 2.08 KB
/
script.js
File metadata and controls
45 lines (36 loc) · 2.08 KB
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
// Write your JavaScript code here!
window.addEventListener("load", function() {
document.getElementById("faultyItems").style.visibility = "hidden";
let form = document.querySelector("form");
form.addEventListener("submit", function(event) {
let pilotInput = document.querySelector("input[name=pilotName]").value;
let copilotInput = document.querySelector("input[name=copilotName]").value;
let fuelInput = document.querySelector("input[name=fuelLevel]").value;
let cargoInput = document.querySelector("input[name=cargoMass]").value;
let list = document.querySelector("input[name=faultyItems]");
if(validateInput(pilotInput) === "Empty" || validateInput(copilotInput) === "Empty"
|| validateInput(fuelInput) === "Empty" || validateInput(cargoInput) === "Empty"){
alert("All Fields Are Required!!");
}
else if(validateInput(pilotInput) === "Is a Number" || validateInput(copilotInput) === "Is a Number"
|| validateInput(fuelInput) === "Not a Number" || validateInput(cargoInput) === "Not a Number"){
alert("Make Sure You Enter Valid Information for each field!!");
}
event.preventDefault();
//console.log(formSubmission);
formSubmission(document, list, pilotInput, copilotInput, fuelInput, cargoInput);
});
let listedPlanets;
// Set listedPlanetsResponse equal to the value returned by calling myFetch()
let listedPlanetsResponse = myFetch();
listedPlanetsResponse.then(function (result) {
listedPlanets = result;
console.log(myFetch);
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 currentPlanet = pickPlanet(listedPlanets);
addDestinationInfo(document, currentPlanet.name, currentPlanet.diameter, currentPlanet.star, currentPlanet.distance, currentPlanet.moons, currentPlanet.image)
})
});