How to find the Max and Min value of a scalar?
-
28-10-2019 - |
题
Okay, so I'm trying to use Javascript to make a Game (Engine?Maybe...). Unfortunately, that means no extremely detailed library like in Visual C#...
So I'm wondering, if I have vector (which is just two variables for right now) and I make that a scalar(multiply those two numbers) then how to i find the min and the max of this scalar?
C#/XNA has a built in Min() and Max(), but I'm trying to do this in Javascript I couldn't seem to find anything on this site, the similar questions on the side don't seem to be of any help... I don't have any code for you because I'm not sure where to start... can someone please help?
解决方案
Javascript also has built in Max and Min functions, e.g.,
var bigNum = Math.max(1,2,3,4,5);
These can be extended to get Max and Min values in arrays (vectors). See this question: JavaScript: min & max Array values?