Build a Golf Score Translator - Build a Golf Score Translator

Tell us what’s happening:

This seems to work. But can you please let me know if this is efficient and scalable?

Your code so far

const names = ["Hole-in-one!", "Eagle", "Birdie", "Par", "Bogey", "Double Bogey", "Go Home!"];
function golfScore(par, stroke) {
  if (stroke-par === 0 && stroke!=1){
    return names[3]
  } else if (stroke-par > 2){
    return names.at(-1)
  }
  return names[stroke-1]
}

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36

Challenge Information:

Build a Golf Score Translator - Build a Golf Score Translator

https://www.freecodecamp.org/learn/full-stack-developer/lab-golf-score-translator/build-a-golf-score-translator

focus first on completing the challenge

What do you mean? Did I not complete it?

not really, if you try other values it does now work.

For example, console.log(golfScore(12, 13)) gives undefined

you created something that passes the tests but does not do what is asked.

1 Like

Oh okay. :disappointed_face: I’ll try again then.