Exactly, so reference forecast instead of LOCAL_FORECAST as the object you are destructuring. Yes, technically both reference the same object, but FCC is trying to teach you a best practice. That best practice is, avoid referencing global variables and instead always pass in the values you need into each function and then reference the local argument variable inside the function.
Ok so now it works. What I don’t understand is how the function “getMaxOfTmrw” gets array data from the global variable “LOCAL_FORECAST”??There is not link between this function and this global constant variable. At least I don’t see one…Or is it implicit?
Anything declared in the global scope has access to anything else in the global scope. LOCAL_FORECAST is in the global scope. The function getMaxOfTmrw is also in the global scope, so the function has access to LOCAL_FORECAST.
The opposite is not possible. For example, if you declared a variable inside getMaxOfTmrw (let’s name it weatherIcons, you would not be able to reference weatherIcons outside of getMaxOfTmrw.
As @hbar1st points out, you do not want to use const here, because then b and a become new variables which are only accessible inside the anonymous function (the IIFE) and then the global variables a and b would not be affected. In this challenge, they actually wanting you to intentionally change the values of the global variables a and b.