Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
(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.
Jeff Lemay14,266 Points
Order 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 KleveterTreehouse Moderator 37,862 Points
The way it works is the PEMDAS, or parentheses, exponents, multiplication and division, then addition and subtraction.
thanks caleb, yes I can see that now
so (2*3) + (2 * 6) is the same as 2*3 + 2*6
Thanks again jeff.