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 trialjohn larson
16,594 Points(2*3) + 2 * 6
the js console says this is = 18: not being brilliant in math by my calculations this should be 48...or maybe 38 ... but in no scenario can I imagine it would be 18.
5 Answers
Jeff Lemay
14,268 PointsOrder of Operations: Multiplication/Division then Add/Subtract
2*3 and 2*6 are run first regardless ( which then gives you (6) + 12 ). If you want it to get forty eight, you need:
(2 * 3 + 2) * 6
Caleb Kleveter
Treehouse Moderator 37,862 PointsThe way it works is the PEMDAS, or parentheses, exponents, multiplication and division, then addition and subtraction.
john larson
16,594 Pointsthanks caleb, yes I can see that now
john larson
16,594 Pointsso (2*3) + (2 * 6) is the same as 2*3 + 2*6
Jeff Lemay
14,268 PointsCorrect
john larson
16,594 PointsThanks again jeff.
john larson
16,594 Pointsjohn larson
16,594 Pointsthank you jeff,