Getting Highest Population and Lowest Population
Keep getting a reference error stating "highestPopulation is not defined at run. The goal of the assignment is to use function printAndGetHighScore to output highest population and lowest population. My question is where do I define highestPopulation within my code?
Voters
On line 72 of "census.1.js", you're referencing the variable
highestPopulation
, which is not defined in that scope. If you want to get the value computed and returned in the functionprintAndGetHighScore
, you should call it (and pass thestatePopulationList
as a parameter):thank you, that got rid of the reference error. Right now the highest and lowest populations are not getting outputted correctly @19wintersp
@tymergoss You've got a couple of issues. The root cause is a bit counter-intuitive; try running this in a JavaScript console:
You should see "what" printed out. This is because of a JavaScript feature (?) known as hoisting. This means that when you call
printAndGetHighScore
on line 72, you're actually calling the function defined on line 81. You can temporarily fix this to test it by commenting out the function starting on line 81.