Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #37578
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2019-10-18 00:44 -0700 |
| References | <be7fd1b4-ac6c-4897-930e-998d5ce4daf2@googlegroups.com> <406e6538-430e-4a3e-ad1f-bd2dd81aa873@googlegroups.com> <abc5921f-655c-4378-84ad-f639b8fc0681@googlegroups.com> |
| Message-ID | <fff1fff6-e24d-4ef5-8273-edff1ea14e00@googlegroups.com> (permalink) |
| Subject | Re: Weather App - one more round? |
| From | luserdroog <luser.droog@gmail.com> |
On Friday, October 18, 2019 at 2:16:40 AM UTC-5, luserdroog wrote:
> On Thursday, October 17, 2019 at 11:05:14 PM UTC-5, Michael Haufe (TNO) wrote:
> > Also, if you're concerned about complexity, there is an objective measure of this that you can use (Cyclomatic Complexity). The JSHint tool provides this as one of its checks:
> >
> > https://jshint.com/
> >
> > Basically lower is better. A score of 10 or above is bad.
> >
>
> I checked my complexity, and I think I'm mostly ok. Median is 2 on
> all files. Max is 18, but I quibble that it's a matter of interpretation.
> It seems to be considering ?: as an enclosing construct, even if I'm
> clever enough to use it without parens. So when I chain 18 of them in
> a row: poof, complexity is 18.
>
> Is there a better way to write this function?
>
Better after a little googling:
compassPoint( d ){
let t = ['N','NNE','NE','ENE',
'E','ESE','SE','SSE',
'S','SSW','SW','WSW',
'W','WNW','NW','NNW','N'];
return t[ Math.round( d / 22.5 ) ];
}
That gets my max down to 5.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Weather App - one more round? luserdroog <luser.droog@gmail.com> - 2019-10-16 21:15 -0700
Re: Weather App - one more round? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2019-10-17 21:05 -0700
Re: Weather App - one more round? luserdroog <luser.droog@gmail.com> - 2019-10-17 21:31 -0700
Re: Weather App - one more round? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2019-10-18 12:42 -0700
Re: Weather App - one more round? luserdroog <luser.droog@gmail.com> - 2019-10-18 00:16 -0700
Re: Weather App - one more round? luserdroog <luser.droog@gmail.com> - 2019-10-18 00:44 -0700
Re: Weather App - one more round? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-10-18 13:23 +0200
Re: Weather App - one more round? luserdroog <luser.droog@gmail.com> - 2019-10-18 13:43 -0700
Re: Weather App - one more round? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-10-18 23:42 +0200
Re: Weather App - one more round? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2019-10-18 12:36 -0700
Re: Weather App - one more round? dr.j.r.stockton@gmail.com - 2019-10-18 02:25 -0700
Re: Weather App - one more round? luserdroog <luser.droog@gmail.com> - 2019-10-18 13:14 -0700
Re: Weather App - one more round? luserdroog <luser.droog@gmail.com> - 2019-10-18 13:35 -0700
Re: Weather App - one more round? luserdroog <luser.droog@gmail.com> - 2019-10-20 21:10 -0700
Re: Weather App - one more round? luserdroog <luser.droog@gmail.com> - 2019-10-20 21:20 -0700
Re: Weather App - one more round? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2019-10-21 04:21 -0700
Re: Weather App - one more round? luserdroog <luser.droog@gmail.com> - 2019-10-21 15:21 -0700
Re: Weather App - one more round? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2019-10-21 16:36 -0700
Re: Weather App - one more round? Julio Di Egidio <julio@diegidio.name> - 2019-10-26 04:20 -0700
Re: Weather App - one more round? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2019-10-26 07:45 -0700
Re: Weather App - one more round? luserdroog <luser.droog@gmail.com> - 2019-10-26 11:06 -0700
Re: Weather App - one more round? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2019-10-26 16:23 -0700
Re: Weather App - one more round? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-10-27 11:05 +0100
Re: Weather App - one more round? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2019-10-27 10:12 -0700
Re: Weather App - one more round? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-10-28 00:44 +0100
Re: Weather App - one more round? Julio Di Egidio <julio@diegidio.name> - 2019-10-28 05:50 -0700
Re: Weather App - one more round? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2019-10-28 06:40 -0700
Re: Weather App - one more round? Julio Di Egidio <julio@diegidio.name> - 2019-10-28 07:00 -0700
csiph-web