0

Stuck in a code

I’m stuck in this code I couldn’t understand what’s the answer, can someone help me with it , - the question was : I should give an output so any price can have discount 20% //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 dis = 20 // mean 20% var newPrice = dis (oldPrice*dis/oldPrice); }

23rd Jan 2021, 4:27 AM
Abdelmalek LAgab
4 Answers
+ 11
20% means 20/100 function main() { var oldPrice = parseInt(readLine(), 10) // your code goes here dis = 20/100 // mean 20% var newPrice = oldPrice - oldPrice*dis; console.log(newPrice); }
23rd Jan 2021, 6:46 AM
Simba
Simba - avatar
+ 10
readline is used for taking a line of input from the user. 10 defines the base of the number. Similarly, 2 is used for binary numbers. We are using console.log since it's mentioned in the task. '//' is used for one line comment in many languages.You can be placed everywhere inside your code. https://www.sololearn.com/learn/JavaScript/1126/
25th Jan 2021, 5:06 AM
Simba
Simba - avatar
+ 1
thank you but i need some answers, what is readLine and why we used 10 ,, why we didn’t use document,write instead of console.log what is the point of ( // mean 20% ) because i tried to change it to let’s say 800% but it still give me correct answer
23rd Jan 2021, 12:40 PM
Abdelmalek LAgab
0
thanks but its still kind of difficult 😔
3rd Feb 2021, 7:30 PM
Abdelmalek LAgab