Path: csiph.com!weretis.net!feeder7.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.javascript Subject: Re: Lazy programmers guide to blizz Date: Fri, 1 Nov 2019 11:04:10 +0100 Lines: 41 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net 2OZZne+cjaNRs3farnPVMwGjbibqCICVKjaR6f2hzBplZfmQxk Cancel-Lock: sha1:6ToR1APuXy9AlxYC9tMgzRkw2UU= In-Reply-To: Content-Language: en-US Xref: csiph.com comp.lang.javascript:37659 On 01.11.19 08:50, Jonas Thörnvall wrote: > It so boring writing if intervals using < > or > < > And hard to read > Why not simplify > > if(A inside.interval(144-159)) > if (A outside.interval(144-159)) > > Maybe there already is interval functions in javascript? > > Alteratively for the operator fixated > if (144< A <159) > if (144> A >159) Hmmm... A inside.interval(144-159) vs. A >= 144 && A <= 160 And you find the first one really simpler? I don't. For example: does inside.interval() mean ">=" and "<=" or ">" and "<"? This is not clear when looking at the code. But if you prefer this, just create your own function - assuming, that the interval means including the lower and upper limit: function between(x, min, max) { return x >= min && x <= max; } -- Arno Welzel https://arnowelzel.de