Tell us what’s happening:
Hello. I can’t figure out why my code doesn’t work. It seems to be identical to the solution, however my code doesn’t return “Par” when strokes = par. I can’t see why.
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 "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 () {return "Go Home!";}
// Only change code above this line
}
// Change these values to test
golfScore(4, 4);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:61.0) Gecko/20100101 Firefox/61.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/golf-code