News for hackers. Stuff that matters.
Re:Math.min(Math.max(num, min), max) by dfabulich on Thursday August 20, 2020 @07:12PM (#24230105)
Beware that in JavaScript, the language that this tweet is about, the sort function sorts alphabetically by default.

    [100, 10, 11].sort()[1] === 100
Re:Math.min(Math.max(num, min), max) by kabacha on Friday August 21, 2020 @01:40AM (#24232313)
Most popular programming language folks. You give it 3 numbers and it treats them as 3 strings of characters...
Re:Math.min(Math.max(num, min), max) by earthboundkid on Thursday August 20, 2020 @10:47PM (#24231463)
Wait, really?

BRB, just checking some code…

Re:Math.min(Math.max(num, min), max) by astrod on Friday August 21, 2020 @01:01AM (#24232139)
Yep, the sort method converts values to strings before comparing. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Re:Math.min(Math.max(num, min), max) by zwaps on Friday August 21, 2020 @04:12AM (#24233043)
I was confused why the author claims this doesn't work, then I saw JavaScript... ah