Basic JavaScript - Golf Code

Tell us what’s happening: below is my code I think I that is correct but on console show me this
SyntaxError: unknown: Unexpected character ‘“’. (9:7)

7 | return “Hole-in-one!”;
8 | }else if((strokes <= par-2)) {

9 | return “Eagle”;
| ^
10 | }else if((strokes === par-1)) {
11 | return “Birdie”;
12 | }else if((strokes === par)) {
What is wrong is that ,show me if you see???

Describe your issue in detail here.

Your code so far

const 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 if((strokes >= par + 3)) {
return “Go Home!”;
}
  return "2 Me";
  // Only change code above this line
}

golfScore(5, 4);

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 6.0; BGO-DL09) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.74 Mobile Safari/537.36

Challenge: Basic JavaScript - Golf Code

Link to the challenge:

Let’s apply some formatting

const 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 if (strokes >= par + 3) {
    return “Go Home!”;
  }
  return "2 Me";
  // Only change code above this line
}

golfScore(5, 4);

Look at the difference between the text coloring for Hole-in-one and Eagle. You used different types of quotation marks. You need to use ‘regular’/‘dumb’ quotes instead of ‘smart’ quotes.

(You can instead index into the names array and use those strings)

1 Like

Thanks I’ve got it.that is good to me

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