+ 5
JavaScript Math Operator 2 Quiz!
I need help solving the JavaScript Math Operator 2 quiz. Can someone please help me. function main() { var oldPrice = parseInt(readLine(5), 10) // your code goes here var newPrice =(oldPrice - 20% ); This is what I have so far
9 Respuestas
+ 4
Okay, a couple of errors:
- readLine() shouldn't take 5 as a parameter. Try removing it.
- Javascript doesn't compute percentages for you, so 20% wouldn't be valid code. Actually, the % operator returns the remainder when a number is divided by a number.
This means that you need to fix newPrice. To calculate it, you need to subtract 20%(which, hint hint, is 0.2 in decimal) of oldPrice from oldPrice.
+ 3
You're super close - to get 20% of oldPrice you need to multiply oldPrice by 0.2;)
+ 2
Thank you 😁👍! I tried 0.2 but it wasn't working for me but I'll try it again
Here's what I changed:
function main() {
var oldPrice = parseInt(readLine(), 10)
// your code goes here
var newPrice =(oldPrice - 0.2 );
I still isn't working
Oh wait I think I know what I forgot
+ 1
Thank you😁👍
+ 1
I still can't get it😂:
function main() {
var oldPrice = parseInt(readLine(), 10)
// your code goes here
var newPrice =(oldPrice * 0.2 );
+ 1
It's a mix of your two answers:
oldPrice = oldPrice - (oldPrice * 0.2);
+ 1
Ooooh thanks I'll try it
+ 1
help me please)
function main() {
var oldPrice = parseInt(readLine(), 10)
// your code goes here
return oldPrice*0,8;
}
isn’t work, why?
+ 1
Try this:
function main() {
var oldPrice = parseInt(readLine(), 10)
// your code goes here
var newPrice = oldPrice - oldPrice/5;
console.log(newPrice);
}