Golf Conditional

I was trying to resolve the challenge, I figure out isn’t the best way but In my logic almost Works. I can’t find the "Logical " error in my code somebody could help me please.
Thanks in advance

In the conditional , below this line, show me error and I don’t Knwo why…

(par===4, strokes===5) { return "Bogey"

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 (par===1,strokes===1) { return "Hole-in-one!" 
} else if 
  (par===4,strokes===1) { return "Hole-in-one!"
   } else if
   (par===4,strokes===2) { return "Eagle"
     }else if
    (par===5, strokes===2) { return "Birdie"
     } else if 
    (par===4, strokes===3) { return "Birdie"
     } else if
     (par===4, strokes===4) { return "Par"
     } else if 
     (par===5, strokes===5) { return "Par"
     } else if
     (par===4, strokes===5) { return "Bogey"
     } else if 
     (par===4, strokes===6) { return "Double Bogey"
     } else if 
     (par===4, strokes===7) { return "Go Home!"
     } else if
     (par===5, strokes===9) { return "Go Home!"
     } else

 return "Change Me";
 // Only change code above this line
}

golfScore(4, 5);

Your browser information:

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

Challenge: Golf Code

Link to the challenge:

Hi Leonardo. Change all your commas to &&. You aren’t comparing anything by using commas there.

1 Like

Thanks @CaraLagumen: It works!!

1 Like

Glad I helped! Have fun with your coding! :blush:

why doing it this way?

don’t you want to try the more satisfying thing to actually have an algorithm that works with any input?
you learn more, in that way

1 Like

Hello @ilenia:

At the beginning I didn’t Understand very well the challenge. I started to “code” an finished but something I felt that I was missing something, the code is with many line and I didnt like, so went to the help and watched the answers. I saw the best way possible to answer the challenge but I will feel like impostor if I do in that way.

I know that it works better with the array and positions and with the conditions: But one thing is Sure, In the future when i see an array I know that I will Work with it. :smiley: :smiley: :smiley: