Heinz
October 27, 2020, 12:36pm
1
Tell us what’s happening:
i think my code is good can anyone tell where im missing my step.
Your code so far
var names = ["Hole-in-one!", "Eagle", "Birdie", "Par", "Bogey", "Double Bogey", "Go Home!"];
function golfScore(par, strokes) {
// Only change code below this line
if (strokes === 1){
return "Hole-in-one!";
}else if (strokes <= (par === - 2 )){
return "Eagle";
}else if (strokes === (par - 1)){
return "Birdie";
}else if (strokes === (par)){
return "par";
}else if (strokes === (par + 1)){
return "Bogey";
}else if (strokes === (par + 2)){
return "Double Bogey";
}else if (strokes <= (par + 3)){
return "Go Home";
}
return "change me";
// Only change code above this line
golfScore(4, 2);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36 Edg/86.0.622.51
.
Challenge: Golf Code
Link to the challenge:
Learn to code. Build projects. Earn certifications.Since 2015, 40,000 graduates have gotten jobs at tech companies including Google, Apple, Amazon, and Microsoft.
solution solved by @lalithakash5
So in the code, I see you have kept a return statement to all the different names like Hole in one, etc the error is you have to keep the return statement to the names[1] names[2] name[3] name[4] name[5] name[6]
Heres the image
This is not comparing what you think it is. Why is the === in there?
Heinz:
par
Capitalization matters!
Heinz:
strokes <= (par + 3)
I don’t think that you mean < here. This admonishment is intended for very large scores.
Heinz
October 27, 2020, 2:32pm
4
i looked at it …asuming it means [4,2] or [5,2]…nothing i do gives me a output.
You do not need double indexing anywhere in this code.
e]
this is not comparing what you think it is . Why you use === in there ?
Heinz
October 28, 2020, 3:36am
7
i fixed all my code and i can get all the code to run but last one…it looks good but i cant find the flaw. the" Go Home"
What is your full current code? I suspect that your comparison is backwards if you didn’t flip the < above (though you should be able to just use an else)
Heinz
October 28, 2020, 7:46pm
9
i got it i was missing a ! sig thanku