69.6k views
0 votes
Write a program to find the largest and smallest numbers in a list.

1 Answer

0 votes

Answer:

const arr = [14, 58, 20, 77, 66, 82, 42, 67, 42, 4];

const min = Math.min(...arr);

const max = Math.max(...arr);

Step-by-step explanation:

This is javascript.

Math.min takes a variable number of arguments, so you use the spread operator (...) to turn the array into a list of arguments.

User Mark Lopez
by
2.8k points