- 1

Math Operator 2 JS

Hello Im new What is wrong? I cant finish this exercise... var price = 100; var discount = 20; var newPrice = price - (price * discount) / 100; console.log(newPrice);

8th Jan 2021, 2:36 PM
Mateusz Wielgat
Mateusz Wielgat - avatar
8 Antworten
+ 5
//Try this function main() { var oldPrice = parseInt(readLine(), 10) //var price = 100; var discount = 20/100; var newPrice = oldPrice - (discount*oldPrice) console.log(newPrice);
8th Jan 2021, 3:41 PM
Simba
Simba - avatar
8th Jan 2021, 2:42 PM
Matias
Matias - avatar
+ 3
Thank you very much. Now I see where was problem I did not take the old price.
8th Jan 2021, 4:52 PM
Mateusz Wielgat
Mateusz Wielgat - avatar
+ 2
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 //so we don’t overwhelm you, we’ve hidden the code that executes the input function main() { var oldPrice = parseInt(readLine(), 10) var price = 100; var discount = 20; var newPrice = price - (price * discount) / 100; console.log(newPrice); I have three test case , Ive pass one but doesn't want to pass the exercise
8th Jan 2021, 3:02 PM
Mateusz Wielgat
Mateusz Wielgat - avatar
+ 1
Hi, this code will pass all 4 tests var oldPrice = parseInt(readLine(), 10) var Price = oldPrice*1 var Discount = 20 var newPrice = Price - (Discount * Price)/100 console.log(newPrice) at least it worked for me ;) Greetings!
10th Aug 2021, 9:57 AM
Nikolaij Cantoni
Nikolaij Cantoni - avatar
+ 1
You need it to transform the price into numeric data. Otherwise the system will come back with no numeric data on the tests.
29th Aug 2021, 9:04 AM
Nikolaij Cantoni
Nikolaij Cantoni - avatar
0
why did you use: var Price = oldPrice*1 ??
25th Aug 2021, 10:22 PM
Pawel
- 1
function main() { var oldPrice = parseInt(readLine(), 10) var Price = oldPrice*1 var Discount = 20 var newPrice = Price - (Discount * Price)/100 console.log(newPrice) }
7th Dec 2021, 12:28 PM
Md. Rakibul Islam
Md. Rakibul Islam - avatar