chingu-voyages / v48-tier1-team-05

A dinosaur app for viewing detailed information about your favorite dinosaurs | Chingu Voyage-48 | https://chingu.io/
https://chingu-voyages.github.io/v48-tier1-team-05/
4 stars 0 forks source link

Move Map Tool variables to javascript module #137

Closed terrifricker closed 5 months ago

terrifricker commented 5 months ago

I had moved the two variables countryCodes and allMaps to the bottom of app.js because to get them out of the way. I was thinking that they were being hoisted. But once we delete the import statement to import the json data, the map tool code stopped working.

Variable declarations are hoisted, but their values are not. Mozilla reference

I decided to move the variables into a javascript module, file map_data.js, and import them into app.js, making them available, but someone reading the code doesn't have to scroll down through all of the continent svg code to get to our app code.

So this pull request deletes countryCodes and allMaps from app.js, copying them into map_data.js. An export line is added to the bottom of map_data.js

export { countryCodes, allMaps }

and the import line is added to the top of app.js.

import { countryCodes, allMaps } from "./map_data.js"

then the reference to map_data.js is added to index.html

<script type="module" src="map_data.js"></script>