Finding a Good Deal explainer

How the program exactly finds the value ? In the compare to maximum function because we didn’t declared anything, like value = flight prices then how the program identify the value we declared??

There is a part of this I don’t understand, the initial max value is the first element in the array(Lets say its 200). When the compareToMaximum function iterates through the flightPrices array and starts at the first element in the array, what does the max value give us true or false;
initial max= 200
max= value>max?value:max;
How does it evaluate this? Is it as true or false

can someone please a screen short of how to do it please

pliz help me by sending a screen short l cant understand it

import { flightPrices } from ‘’;

let max = flightPrices[0];
let min = flightPrices[0];

function compareToMaximum(value) {
max = value > max ? value : max;

function compareToMinimum(value) {
min = value < min ? value : min;


console.log('Maximum: ’ + max);

console.log('Minimum: ’ + min);

That should help you :smiley:

don’t write spoiler sorry!!!

How come the variables “max” and “min” can be used inside different functions if they were declared as “let”? I thought “let” had a local scope, and var had a more global scope? Shouldn’t max and min be declared “var max” and “var min” ?

hi pls help I am stack

It all comes to where a “let” variable was created.
If “let” (local scope) variable was created inside of a function, it’s usability is restrained to a scope of that function;
If “let” variable was created outside of a function - it can be used inside of a function as well since it’s scope includes that function.