Golf score(5,2) should return "Double Eagle"

Tell us what’s happening:
5,2 should not return eagle it should return double eagle. Your test is incorrect.
Your code so far


var names = ["Hole-in-one!", "Double Eagle", "Eagle", "Birdie", "Par", "Bogey", "Double Bogey", "Go Home!"];
function golfScore(par, strokes) {
// Only change code below this line
if (strokes - par >= 3) {
  return names[7];
}
else if (strokes - par == 2) {
  return names[6];
}
else if (strokes - par == 1) {
  return names[5];
}
else if (strokes == par) {
  return names[4];
}
else if (strokes - par == -1) {
  return names[3];
}
else if (strokes - par == -2) {
  return names[2];
}
else if (strokes - par == -3) {
  return names[1];
}
else {
  return names[0];
}

// Only change code above this line
}

golfScore(5, 4);
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15.

Challenge: Golf Code

Link to the challenge:

Hi,

2 things:

  1. “Double Eagle” does not exist!
  2. Use if (strokes == 1) {return names[0]; } at the beginning!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.