Creating a loop
Just like Task #8, just study the block of code that creates a “for loop”. Do not modify i!!
The “for loop” allows the program to loop through the data arrays you have worked with above, performing the multiplication function from Task # 8 for each object in the arrays. So it will take the first entry from each array and walk through the function created above, and then the next. And when it has looped through all the values, it will move on. (For more information on loops, go here.)
Note: within the loop, you see reference to the arrays modified in previous tasks. For instance, the first line mentions “cs.length”. This is telling the program to run through this loop for each instance within the cs array that list names of cheesesteak locales (i.e., the length is 6 because there are six locations in the list). You’ll notice that the loop also creates a new variable YelpFactor by working with the csStar and csReviews arrays from above within the loop.
Please don’t touch the for loop!
Inside this for loop is also a method, .bindpopup. Essentially, you are telling the program what to include in the information that is included in a Google Map pop up. (To find more about methods here.)
As I mentioned – we are sending a request to an external server through the internet. This ‘leaflet’ server which we have a link to in the header of our .html file then spits back the map (and it’s functionality) that we see on the screen.
If you’re curious, here’s some documentation on the leaflet server: http://leafletjs.com/reference-1.0.3.html.
Question: Explain your process a bit, the choices you make, and the result. Think about the code specifically. Can you see the results of your modifications on the resulting map?
Paste your resulting map into this lab.