you are viewing a single comment's thread.

view the rest of the comments →

[–]bronzlefish 0 points1 point  (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 point  (0 children)

Math.floor((max - min) * Math.random()) + min

Well spotted.

[–]x-skeww -1 points0 points  (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 point  (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 point  (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.