The Peak Score

MediumAcc. 91.8%
+25 XP 10

Leading Strategy

To find the maximum value, you compare each element against a "current leader" variable.

The Assignment

Your function receives an array scores.

  1. Initialize max with the first element of the array (or a very small number).
  2. Loop through the array starting from index 1.
  3. If the current score is greater than max, update max.
  4. Print the final max.

01EXAMPLE 1

Inputscores = [5, 15, 8, 10]
Output15

Explanation: 15 is the highest.

Constraints

  • Do not use Math.max(...array).
  • Handle the case where all numbers are negative.
ArraysLoopsSearch
JavaScript
Loading...
2 Hidden

Input Arguments

scores[5,15,8]

Expected Output

15

Click RUN to test your solution