Math.min

Category:Math

Math.min(n1, n2, ..., nX)

Category: Math

Returns the minimum value among one or more values n1, n2, ..., nX.

Some apps need to know the minimum number from a collection of numbers or variables. You can call Math.min with zero, one or more parameters, depending on how many numbers you want to compare.

Examples


var a = Math.min(5, -2);
console.log(a);
var x=9;
var y=12;
var b = Math.max(x,y);
console.log(b);

var a = Math.min(5, 0, 21.5, 13, -2);
console.log(a);

Syntax

Math.min(n1, n2,..., nX);

Parameters

Name Type Required? Description
n1, n2,..., nX number No One or more numbers or variables to compare.

Returns

A number representing the lowest of the values given as parameters, or infinity if no arguments are given, or NaN if one or more arguments are not numbers.

Found a bug in the documentation? Let us know at documentation@code.org

Found a bug in the documentation? Let us know at documentation@code.org