0
JavaScript if else
Why is there a error?? var height = parseFloat(readLine(), 10) //your goes code here if (height >= 2.45); { console.log ("new record!"); } if else (height >= 2.44) { console.log ('not this time!'); }
10 Réponses
+ 3
var height = parseFloat(readLine(), 10)
//your goes code here
if (height > 2.45) {
console.log ('new record')
}
else if (height < 2.44) {
console.log ("not this time")
}
Good Luck
+ 2
Remove the (height >= 2.44) part: You only want to know if someone beats the record. If not he/she must me smaller (else)
+ 1
1. That else if{} not if else{}
2. remove semicolons on the end of if line
var height = parseFloat(readLine(), 10)
//your goes code here
if (height >= 2.45)
{
console.log ("new record!");
}
else if (height >= 2.44)
{
console.log ('not this time!');
}
+ 1
From how I understand your code, I'd suggest to use only "else" on the second part (no "else if")
+ 1
Thanks a lot!!
0
Im confused dont i need an if statement?
0
I don't know what the task is (I can't see the pro projects) but I think you need both:
if (condition) {
...
} else {
...
}
0
Another issue: If you read the task instruction again, you'll find that it needs to be
if (height > 2.45) ...
(Not >=)
0
var height = parseFloat(readLine(), 10)
//your goes code here
if (height > 2.45) {
console.log ('new record')
}
else if (height < 2.44) {
console.log ("not this time")
}
0
if(height < 2.45){
console.log("not this time")
} else {
console.log("new record")
}