r/javaScriptStudyGroup • • May 10 '16

CHALLENGE: Write a multiplication function...

CHALLENGE:

Write a multiplication function that takes two numbers integers as arguments and returns their product.

Rules:

  1. Cannot use * or / operators

  2. Cannot use Math object

  3. Cannot use for (any variation) or while (including do) loops

2 Upvotes

17 comments sorted by

View all comments

Show parent comments

2

u/Volv May 10 '16

How about this

1

u/ForScale May 10 '16

Aha! No, I don't consider that cheating. That fill method... nice!! Wait till you see my solutions, the first one certainly could have used fill. Thanks for the heads-up on it!

And whats the 0 argument in the reduce function? Is that starting index?

2

u/Volv May 10 '16

yep, exactly.

1

u/ForScale May 10 '16

Cool. Nice work with the challenge and the one-liner! It just came to me for some reason so I thought I'd post it here. Let me know your thoughts on my solution when you get a chance! Obviously no rush or anything.