0

Js course 7.2 practice

Time to go shopping! Everything in the store has been discounted by 20%. You are given a program that takes the price of an item as input. Complete the program so that it outputs the discounted price to the console. Sample Input 100 Sample Output 80 Explanation 20 percent of 100 equals to 20 (100 * 20/100), so the discounted price will be 80 (100 - 20). Note: Remember the division (/) and multiplication (*) operators. ---------code------------ //so we don’t overwhelm you, we’ve hidden the code that executes the input function main() { var oldPrice = parseInt(readLine(), 10) // your code goes here } -----------end of code------------- That's my problem, I can't answer that. What should I do? I can't understand the question. "//your code goes here" is the place I should put my answer. What code should I write.

22nd Dec 2021, 10:13 AM
Jonathan P. Jundarino
Jonathan P. Jundarino - avatar
10 Antworten
+ 2
The given code just tells you that there is the variable oldPrice. Use oldPrice for the calculation. We need to find a newPrice. newPrice is the reduced price. Reduction is 20% of oldPrice Hence, newPrice = oldPrice – reduction. Calculate reduction, calculate newPrice. Output newPrice using console.log
22nd Dec 2021, 11:18 AM
Lisa
Lisa - avatar
+ 2
The only thing you need to do is to calculate the reduced amount of oldPrice and output it to the console
22nd Dec 2021, 11:00 AM
Lisa
Lisa - avatar
+ 1
What is your question?
22nd Dec 2021, 10:34 AM
Lisa
Lisa - avatar
+ 1
Lisa Thanks, I use console.log(), I just solve the quiz.
22nd Dec 2021, 11:34 AM
Jonathan P. Jundarino
Jonathan P. Jundarino - avatar
+ 1
Great! 👍
22nd Dec 2021, 11:34 AM
Lisa
Lisa - avatar
0
Lisa thanks for your comment, my discus button have error. Now I can edit this.
22nd Dec 2021, 10:50 AM
Jonathan P. Jundarino
Jonathan P. Jundarino - avatar
0
Lisa I need your help, I tried creating new variable inside that function, there's no parameter also to make argument. I tried to call the function, but nothing happen. It's supposed to be basic, because it's quiz for js operations. The function lesson is far. I can't understand.
22nd Dec 2021, 10:56 AM
Jonathan P. Jundarino
Jonathan P. Jundarino - avatar
0
"//your code goes here" is the place I should put my answer. What code should I write Lisa
22nd Dec 2021, 10:58 AM
Jonathan P. Jundarino
Jonathan P. Jundarino - avatar
0
Lisa I'm sorry, I really can't understand, can you spoon feed me the answer? 😂😅🙄🙏. I can't understand the "var oldPrice = parseInt(readLine(), 10)" It looks like I'm not supposed to see that base on the comment //.
22nd Dec 2021, 11:11 AM
Jonathan P. Jundarino
Jonathan P. Jundarino - avatar
0
Try this :---–------ function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here var j=prices.length ; for(i=0;i<j;i++){ prices[i]= prices[i]+increase; } console .log(prices); }
23rd Dec 2021, 2:15 PM
Kamlesh Sakre
Kamlesh Sakre - avatar