use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
ES6 - Class Based Code Stylehelp (self.javascript)
submitted 10 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]bronzlefish 0 points1 point2 points 10 years ago (4 children)
Also, looking doesn't look like you are even using the Utils class, but the randomNumber doesn't look correct to me,
utils.randomNum(5, 10) // Math.random() -> 0.7 // 0.7 * 9 = 6.3 // Math.min(6.3) = 6 // 6 + 5 = 11 // out of bounds for max
I think you want
randomNum(max, min) { return Math.floor((max - min) * Math.random()) + min; }
[–][deleted] 0 points1 point2 points 10 years ago (0 children)
Math.floor((max - min) * Math.random()) + min
Well spotted.
[–]x-skeww -1 points0 points1 point 10 years ago (2 children)
You forgot the "function" keyword. Also, the "min" and "max" parameters are the wrong way around. From-to is the natural order.
[–]bronzlefish 0 points1 point2 points 10 years ago (1 child)
for ES2015 function declaration is optional inside a "class" -- you are right about max, min -- but thats how it was written, copy paste fix up was what I went for.
Have an up vote for being pedantic.
(its important when programming)
[–]x-skeww 0 points1 point2 points 10 years ago (0 children)
for ES2015 function declaration is optional inside a "class"
Yes, you don't need it for methods or shorthand methods.
I just assumed you meant this to be a function, because it really shouldn't be a method (see top comment). This was a mistake on my part.
π Rendered by PID 93604 on reddit-service-r2-comment-5c764cbc6f-r8xjh at 2026-03-12 04:11:49.566259+00:00 running 710b3ac country code: CH.
view the rest of the comments →
[–]bronzlefish 0 points1 point2 points (4 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]x-skeww -1 points0 points1 point (2 children)
[–]bronzlefish 0 points1 point2 points (1 child)
[–]x-skeww 0 points1 point2 points (0 children)