T
T
Tigran Aginyan2021-07-02 22:58:13
JavaScript
Tigran Aginyan, 2021-07-02 22:58:13

Can Math.max be used on arrays?

I want to use Math.max to find the largest number in the array, but the function returns null. How can I get around this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Ineshin, 2021-07-02
@Tigran1991

const foo = [1,2,3,4,5];
console.log(Math.max(...foo));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question