Skip to content

Commit

Permalink
Merge pull request #144 from LaunchCodeEducation/mike-issue-36
Browse files Browse the repository at this point in the history
Cleaned up section on scriptHelper a bit and added a note about async await
  • Loading branch information
johncfrauen-lc101 authored Sep 9, 2024
2 parents ed583b4 + 26f77c6 commit 2e68c13
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions content/assignments/launch-checklist/planet-fetch/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,29 @@ Our planetary data can be found in [JSON format](https://handlers.education.laun
Review the list and decide which planet you want to send our intrepid crew to and make note of the index number.

{{% notice blue "Note" "rocket" %}}

When fetching more than one JSON object, we get an array of all of the JSON objects.
In this case, that means an array of our possible mission destinations.
When picking the mission destination, just pick the item in the array you want and start counting at 0.

When fetching more than one JSON object, we get an array of all of the JSON objects.
In this case, that means an array of our possible mission destinations.
When picking the mission destination, just pick the item in the array you want and start counting at 0.
{{% /notice %}}

In `scriptHelper.js`, you have three functions for this task: `myFetch()`, `pickPlanet()`, and `addDestinationInfo()`.

First, review the comments in `addDestinationInfo()`.
This is the format of the `innerHTML` for the `missionTarget` div, which you can locate using the `document` parameter of `addDestinationInfo()`.
`addDestinationInfo()` does not need to return anything.
This is the format of the `innerHTML` for the `missionTarget` div, which you can locate using the `document` parameter of `addDestinationInfo()`. `addDestinationInfo()` does not need to return anything.

`pickPlanet()` takes in one argument: a list of planets. Using `Math.random()`, return one planet from the list with a randomly-selected index.
`myFetch()` has some of the code necessary for fetching planetary JSON, however, it is not complete. You need to add the URL and return `response.json()`.

`myFetch()` has some of the code necessary for fetching planetary JSON, however, it is not complete. You need to add the URL to the `fetch` method call and return `response.json()` from the inner function.


{{% notice blue "Note" "rocket" %}}
`myFetch` has an `async` prefix prior the function declaration, and also uses the `await` keyword
in the body.

This is an advanced language feature used by the autograder that you do not need to worry about for
class.
{{% /notice %}}


Now it is time to make use of these helper functions in `script.js`. We provided some of the code necessary:

Expand Down

0 comments on commit 2e68c13

Please sign in to comment.