Build a Golf Score Translator - Build a Golf Score Translator

Tell us what’s happening:

Even though my code seems to run fine and output what it needs to in the console, it doesn’t pass the tests like ‘golfScore should return a string’ & 'golfScore(4, 1) should return the string ‘Hole-in-one!’. I thought the issue was that it wasn’t a string(?), but I’ve changed all my returns to convert the object into a string, and it still isn’t passing. would someone be able to explain what’s wrong or missing, or if it’s some sort of bug instead?

Your code so far

const names = ["Hole-in-one!", "Eagle", "Birdie", "Par", "Bogey", "Double Bogey", "Go Home!"];

function golfScore(par, strokes){
    if(strokes > 1){
    if(strokes <= par - 2){
      return console.log(String(names[1]))
    }
    else if(strokes === par - 1){
      return console.log(String(names[2]))
    }
    else if(strokes === par){
      return console.log(String(names[3]))
    }
    else if(strokes === par + 1){
      return console.log(String(names[4]))
    }
    else if(strokes === par + 2){
      return console.log(String(names[5]))
    }
    else if(strokes > par + 3){
      return console.log(String(names[6]))
    }
  }
  else{
    return console.log(String(names[0]))
  }
} 
  

  golfScore(1, 1);
  golfScore(5, 4);
  golfScore(3, 1);
  golfScore(5, 2);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:152.0) Gecko/20100101 Firefox/152.0

Challenge Information:

Build a Golf Score Translator - Build a Golf Score Translator

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-golf-score-translator/689f7996426c1534fa5bea66.md at main · freeCodeCamp/freeCodeCamp · GitHub

Hi @greengravel,

This is invalid syntax. We don’t return a log. If you want to see what your function returns, wrap your function call in console.log(). You also don’t need to apply a String() constructor. Your array items are already strings.

Happy coding

thank you so much for explaining that !!! i fixed it up and completed the lab :]