课程: JavaScript Essential Training

今天就学习课程吧!

今天就开通帐号,24,600 门业界名师课程任您挑!

Challenge intro: Calculate sales tax

Challenge intro: Calculate sales tax

(upbeat music) - [Instructor] Computers are really good at doing mathematical calculations. That's why they're called computers. And working with JavaScript, you'll often use math formulas to accomplish tasks. In this challenge, you'll get to try this for yourself by creating a basic sales tax calculator for a store. In the test code setup, you'll find an almost completed setup to calculate taxes and totals for a store in British Columbia, Canada. There are two taxes here, the GST, which is 5%, and the PST, which is 8%, and both of these taxes need to be applied independently to the before tax total to get the final price. Your task is to complete the calculateTotal function by adding GST, PST, and sum properties to the totals objects and performing the necessary math to get the right numbers in each property. You can see at the bottom here that all this information gets output at the end and you want this output to…

内容