Question about GOLF

Tell us what’s happening:

W hat’s wrong? If I put in the values in the console,it seems that got I it correct.

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

console.log (golfScore(5,9))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362.

Challenge: Golf Code

Link to the challenge:

You changed code below
// Only change code above this line

look at the tests you are failing, and check your strings. Those failing have most probably the strings written wrong.

to avoid this you could use the elements from the provided array instead of hard-writing the strings inside the function

1 Like