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 trialDimitris Karatsoulas
5,788 PointsHow and why is the log of the processSale function shown in that way?
In Challenge 2 at the end of the challenge function processSale () is run by referring it in the console.log()
"console.log("Total sale: $" + processSale(product, 3));"
even though in the code the function is referred after the "Total sale..." part we can see in the console that the log "3 chairs were sold" is print before the "Total sale..." part. Can anyone please explain that behavior?
1 Answer
seth aruby
10,111 PointsDimitris, since the processSale function first logs the quantity sold to the console (ie, prior to returning the total sale), then the quantity sold is displayed prior to the total sale. Hope this helps.