javascript - How to calculate the proper numbers without doing a switch? -


i need algorithm calculate offset based on array length. have manually got number each number, if possible without doing case/switch.

given array length x, need come calculates this:

20 if x == 5 25 if x == 4 35 if x == 3 50 if x == 2 

am missing something? have use switch here?

a random guess, how 105 div x?

or maybe round(20 / x) * 5?

in fact, since gave 4 cases, there lot different methods can use. perhaps more importantly - there patterns follow enables code make more sense?


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -