Golf Course Help! PleasE!

Tell me what’s happening:

I don’t what’s happening, it looks fine to me but its wrong!

My 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
  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!"
else {
  return "Change Me"
// Only change code above this line

golfScore(5, 4);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36.

Challenge: Golf Code

Link to the challenge:

this is a comparison, good

here you are assigning par-1 to strokes which is not what you want to do

@ieahleen So what do I do ?
It just doesn’t move ahead of that birdie thing

do you want to check the value of strokes, or assign a value to strokes?

Uhmmmmmmmm Compare I think!

then adjust your code so that the comparison is what’s happening and not the assignment

1 Like

@ilenia Ooh thanks I just put strict operator there and it’s working


happy coding

@ilenia May I ask you something?

Just before what I was doing was wrong, Why?
Aren’t both the values int?

if you mean why it doesn’t work with =, it’s because that operator assigns a value to a variable, it doesn’t compare two values

a = b; // assign the value of b to a

c === d; // compare the value of the two variables
1 Like

Not even in the if statement?

it’s an assignment operator.

if you want to compare two values you need to use === or ==

1 Like

Ooooooooooooh okay!
Thanks a lot!!!