Question #5 of assignment 4

var num2 = [10, 20, 53, 55, 44, 95, 85, 71, 72, 64];

	document.writeln(Math.max(10, 20, 53, 55, 44, 95, 85, 71, 72, 64) + "<br>");
	document.writeln(Math.min(10, 20, 53, 55, 44, 95, 85, 71, 72, 64) + "<br>");

Direct through number it is working. But when I am passing var num2 it is not working. Can you please help me here.

its working

var n1=10, n2=200, n3=30, n4=5, n5=60
console.log(Math.max(n1, n2, n3, n4, n5))           // result 200

The truth is Array is not same as a single number. You doing like One bag of Rice vs one rice . There are other ways to loop through Array to get its items.

But in ES6 spread operator introduced you can spread array into individual items like this.

var nums = [2 ,45, 23, 565, 1]
console.log(Math.max(...nums))      // result 565

Thank you! It is helpful.