Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #38768
| Newsgroups | comp.lang.javascript |
|---|---|
| Subject | Re: Number not greater or less than two limits |
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
| References | <aZidnYDptsznPsTCnZ2dnUU7-XnNnZ2d@westnet.com.au> <slrnrlk38q.ja8i.jon+usenet@raven.unequivocal.eu> |
| Date | 2020-09-10 15:00 +0200 |
| Message-ID | <XnsAC3498AFECBE1eejj99@194.109.6.166> (permalink) |
Jon Ribbens wrote on 10 Sep 2020 in comp.lang.javascript: > value = min(maximum_value, max(minimum_value, value)) const clamp = (mini,valu, maxi) => Math.min(maxi, Math.max(mini, valu)); let res = clamp(1, 2, 3); console.log( res ); // 2 res = clamp(1, 4, 3); console.log( res ); // 3 res = clamp(1, 0, 3); console.log( res ); // 1 -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Number not greater or less than two limits Andrew Poulos <ap_prog@hotmail.com> - 2020-09-10 13:54 +1000
Re: Number not greater or less than two limits "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-09-09 23:09 -0700
Re: Number not greater or less than two limits Julio Di Egidio <julio@diegidio.name> - 2020-09-09 23:56 -0700
Re: Number not greater or less than two limits Andrew Poulos <ap_prog@hotmail.com> - 2020-09-10 17:44 +1000
Re: Number not greater or less than two limits Jon Ribbens <jon+usenet@unequivocal.eu> - 2020-09-10 11:25 +0000
Re: Number not greater or less than two limits "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-09-10 15:00 +0200
Re: Number not greater or less than two limits "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-09-10 15:59 +0200
Re: Number not greater or less than two limits Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2020-09-10 19:01 +0200
Re: Number not greater or less than two limits John G Harris <niam@jghnorth.org.uk.invalid> - 2020-09-11 16:04 +0100
csiph-web