From 328b523c71b805d12d8fe8fabee8390111f063af Mon Sep 17 00:00:00 2001 From: iamnithishraja Date: Fri, 12 Jan 2024 11:08:37 +0530 Subject: [PATCH] max and min now evaluates correctly max and min now evaluates correctly even on numbers in strings --- src/math/calculation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/math/calculation.js b/src/math/calculation.js index efe6b6733e..77d9239750 100644 --- a/src/math/calculation.js +++ b/src/math/calculation.js @@ -473,7 +473,7 @@ p5.prototype.max = function(...args) { const findMax = arr => { let max = -Infinity; for (let x of arr) { - max = x > max ? x : max; + max = Math.max(max, x); } return max; }; @@ -551,7 +551,7 @@ p5.prototype.min = function(...args) { const findMin = arr => { let min = Infinity; for (let x of arr) { - min = x < min ? x : min; + min = Math.min(min, x); } return min; };