to return the value “Par” both the stroke and par should be the same eg:(4,4)or (5,5) i used the equality operator but the the console says it’s wrong
**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 names[0];
} else if (strokes <= par - 2){
return names[1];
} else if (strokes = par - 1){
return names[2];
} else if (strokes === par ){
return names[3];
} else if (strokes == par + 1){
return names[4];
} else if (strokes == par + 2){
return names[5];
} else {
return names[6];
}
return "Change Me";
// Only change code above this line
}
golfScore(4,4);
**Your browser information:**
User Agent is: <code>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36</code>
**Challenge:** Golf Code
**Link to the challenge:**
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/golf-code
yes it is not supposed to be there sorry i made a mistake and i forgot to change that it should be the same as else if (strokes = par - 1) instead with a + operator
omg i made a huge mistake i just reread your comment about equality operator and read the code back from top to bottom that’s when i realised i used assignment operator in the second else if statement strokes = par - 1
i feel so stupid i was looking below 3rd else if statement because the value “Birdie” was displaying without a problem.