One Pager Cheat Sheet
- You can find the
maximum
andminimum
value of an array using JavaScript by creating it and accessing its elements. - The
index
of the array determines its minimum value, which in this case is 2, the smallest number of the entire array. - We
set
theminimum
variable toInfinity
and themaximum
variable to-Infinity
to compare values correctly. - Yes, Infinity is greater than 5,000,000 because it is an
unbounded number
that is higher than any assignable quantity. - Using a For Loop, a comparison of the values inside the array is conducted to find the
maximum
andminimum
values and output them to theconsole
. - Utilizing Javascript's built-in functions,
Math.min
andMath.max
, we can create our own functions to find the minimum and maximum of an array. - The for loop iterates through the
array
and stores thelargest
andsmallest numbers
in themaximum
andminimum
variables which are outputted as"Max Value: 60"
and"Min Value: 2"
. - The code uses a
for loop
to compare each number in the array and updates the values ofminimum
andmaximum
according to the result, then usesgetMaxOfArray
andgetMinOfArray
functions to return the maximum and minimum values.