Rspec_1 exercise TDD #multiply multiples several numbers

Hi,

I need help with understanding what is required here.

  • The functionality “multiples two numbers” is understood
  • How do we go about implementing the method to satisfy the the second spec “multiplies several numbers” ?
  • Will the multiply method take two arguments? Or some flexible number of integer arguments?

multiply

Make use of the #reduce method to multiply several nums in an array.

2 Likes

For this multiply method, there will only be one argument in the form of an array, but I do encourage you to think about how to approach this problem if you are given multiple arguments.

Michael

Have it take an array and multiply all the elements of the array together.
So multiply([2, 4, 6]) should return 48.

Alternatively you can use *args to make it so you can call it like this: multiply(2, 4, 6)