javascript write a function that takes a list of numbers and returns the largest number in the list. if there are no numbers in the list, return 0. code example
Example 1: greater number in arraya jd
var array = [3 , 6, 2, 56, 32, 5, 89, 32];
var largest= 0;
for (i=0; i<=largest;i++){
if (array[i]>largest) {
var largest=array[i];
}
}
console.log(largest);
Example 2: get largest number in array javascript
const array1 = [1, 3, 2];
Math.max(...array1);
// expected output: 3