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
douglas mowat
1,828 Pointsthis is a ruby quiz,need help please.Set the variable"product"to be a multiple of the variable"a"and"b",a=6,b=2
how would you write this in ruby
3 Answers
Mo Daka
Courses Plus Student 10,363 Pointsyou 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
Mo Daka
Courses Plus Student 10,363 Pointsa = (6*2)
douglas mowat
1,828 Pointsjustin is there any other answer that might work