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); }
4 Respuestas
+ 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);
}
+ 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/
+ 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
0
thanks but its still kind of difficult 😔