From 7518251bddf362759cb5789ec537711e9d86b0df Mon Sep 17 00:00:00 2001 From: Amir Walker Date: Thu, 3 Sep 2026 13:42:25 -0700 Subject: [PATCH] Changed the if condition from i to num --- 2-js-basics/4-arrays-loops/array.js | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/2-js-basics/4-arrays-loops/array.js b/2-js-basics/4-arrays-loops/array.js index 6279f460b..a40c8de24 100644 --- a/2-js-basics/4-arrays-loops/array.js +++ b/2-js-basics/4-arrays-loops/array.js @@ -22,22 +22,11 @@ console.log(NumPattern()); numbers = [8,393,200,700,4,2000,638,29999] function findMaximum(){ -let max = numbers[0]; - - for (let num of numbers){ - if (max < numbers[i]){ - max = numbers[i]; - } - } -return max; -} - -function findMaximum1(){ let max = 0; - for (i = 0; i < numbers.length; i++){ - if (max < numbers[i]){ - max = numbers[i]; + for (let num of numbers){ + if (max < num){ + max = num; } } return max; @@ -47,4 +36,4 @@ return max; console.log(findMaximum()) -console.log(findMaximum1()) \ No newline at end of file +//console.log(findMaximum1()) \ No newline at end of file