Minimum value of an array using reduce

I have this code that seems like it would work. I am using the reduce method on an array of numbers as slips of paper drawn from a box. Reduce should output the minimum value. The accumulator is the number to compare the current value against. I believe 100 would be compared against the first number in the array, the result of finding of the minimum would compare to the second value in the array and so on.
Running it on the repl environment yields “Unexpected token ‘=>’.” What is jamming it?

let numberDrawn = [56, 45, 52, 39];
const findMin = numberDrawn.reduce((accumulator, slip)
=>	Math.min(accumulator, slip), 100

That’s not legal JS when using the arrow function. You are going to have to use curly braces. There is an example of how to do this at:

Retyping the variable and adding a console log of it worked. Thanks all.

Look at the Line breaks rules.

Both below should work:

numberDrawn.reduce((accumulator, slip) => Math.min(accumulator, slip), 100);
const findMin = numberDrawn.reduce(
  (accumulator, slip) => Math.min(accumulator, slip),
1 Like

Ahh, you’re right, that one slipped by me. No need for curly braces, just have to keep it all on one line.