Improve this JavaScript function #shorts

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

I love this. Yea, you showed how to use the set concept. However, more importantly, you showed how to gracefully take feedback, adapt, and show the importance of code reviews and feedback loops!

michaeljmeyer
Автор

Line 15, I keep always the comparision order from small to big. So first thing I would have done is changing the "size > max" to "max < size". This approach makes code cleaner for me :)

jakubwikacz
Автор

Math.random gives a number between 0 (inclusive), and 1 (exclusive). Therefor, Math.ceil(Math.random) might gives you 0 if random happens to return exactly 0. Be careful!

amywyvern
Автор

You could also switch it to a generator function

RodyDavis
Автор

I liked your theme which one you using?

osaif
Автор

check max not size.

Personally I'll put the check before making the set. Because if it's error it's one less line of code run, but that's preference.

IIRC random can give 0, it's really unlikely tho. But using floor then +1 would guarantee it's between 1 and Max

chervilious
Автор

Good day can you do the amplify nexttoken tutorial in react J's.. thank you so much :)

mackyboy