セクション 5. 章 4
single
Challenge
メニューを表示するにはスワイプしてください
Let's practice!
タスク
スワイプしてコーディングを開始
Lily went to the shop to buy some clothes. It was the sales day so all the clothes she bought were at discount. Let’s calculate the total discount she got.
We have two arrays of the same length (6): prices and sales. The first array stores prices (in dollars) for Lily’s clothes and the second one stores discounts (in percent, 0.1 means that the thing has a 10% discount) for the corresponding clothes.
You should:
- Use for loop to go through the arrays, don't forget to open curly brackets.
- Calculate the discount for each thing by multiplying the corresponding elements of two arrays and store the result in the variable
discountForEach.
- To find the sum of all discounts, add variables
discountForEachandtotalDiscount, and store the result in the variabletotalDiscount.
- Close curly brackets.
- Print the variable
totalDiscount.
Please, don’t forget to type the semicolon at the end of the lines.
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 5. 章 4
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください