Bummer! You must be logged in to access this page.

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

iOS

Given the height and width of a wall in inches... But I don't understand?

Okay It says: Given the height and width of a wall in inches, calculate the area in feet and assign it to a constant named areaInFeet

let height = 120.0 // in inches
let width = 144.0 // in inches

Now answers in the forums are:

let areaInFeet = (height / 12) * (width / 12)

Which is correct. But I don't understand. Where is the number 12 coming from? and why wasn't this taught in the lesson? I watched the video over 5 time. When I go back in this I don't understand and forget the answer because the code was never teaching us this way?

Please someone if they can help.

Regards, Wahid Fayad

3 Answers

Wahid

In the American measurement system, 1 foot = 12 inches. That is where the number 12 comes from. Because the values are specified in inches, you must turn them into feet as that is what it is asking you to do. Hope that helped.

       let  areaInFeet = height * width
       // areaInFeet = 17,280.0 inches

      let areaInFeet = (height / 12) * (width / 12)
      // areaInFeet = 120.0 ft.

Okay sure.

But I had a few friends now calculate the areaInFeet which = to: 144.0 ft. How was the answer: 120.0 ft?

Here's my math:

120.0 / 12 = 10.0 144.0 / 12 = 12.0

To find the area we multiply 10.0 * 12.0 and get 120.0

I also tried leaving out the () but the result I got was still 120.0 for area. The only way only way I could see getting 144.0 is if they may have used width twice on accident.

Oh yes. So sorry now I understand how this works. I was probably just confused to get the answer written in this format below. Which it doesn't explain in previous tutorials to do it this way or only if I was not paying attention.

(height / 12) * (width / 12)

Thanks Michael for your help!