Tell us what’s happening:
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
return "Go Home!";
// Only change code above this line
}
golfScore(5, 4);
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0
.
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.
If you had used the array given to you it wouldn’t have been a problem. Not saying you have to use it, but it would have helped in this case.
2 Likes
SGirma
July 31, 2020, 8:12pm
4
@ferrerioo1988 refer back to Access Array Data with Indexes section and take advantage of the array already typed out for you. This not only helps you avoid typing mistakes, if later on you want to change some things, you’d only have to do it at one place.
1 Like
pardes
July 31, 2020, 10:07pm
5
you have missed simicolons after returning statements.
1 Like
I did it with the array, and it worked.Thanks.