Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Basics (Retired) Ruby Numbers Multiplication and Division

Andrew Woods
Andrew Woods
17,373 Points

Set the variable "product" to be a multiple of the variables "a" and "b".

this is most likely the simplest answer, but i have reviewed the video lesson and cant seem to find the answer. I tried variations of
a = 2 b = 2 a * b = c etc etc.

1 Answer

Stone Preston
Stone Preston
42,016 Points

you need to create a new variable named product, and on the right side of the = assign it the product of a and b

when working with variables and assigning them values, the variable name goes on left side of the equals sign, and the value you want to assign it goes on the right.

creating a variable generally looks like this:

variable_name = value

Ruby can do mathematical operations using operators such as *, / -, and +.

if we wanted to create a variable called sum and assign it a value of 2 + 3 it would be

sum = 2 + 3

if we had assigned 2 and 3 to variables it would be:

a = 2
b = 3
sum = a + b

so to assign a variable called product the product of a and b:

a = 6
b = 2
product = a * b
Andrew Woods
Andrew Woods
17,373 Points

Thanks Stone, it worked, i knew it was something incredibly simple. not very useful tips on that test to help you.

Thanks again for the speedy help

Cheers