Basic JavaScript - Golf Code

I have searched the forum and seen other ways to do this but im wondering why the following code won’t return eagle?

const 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) {
  return names[0];
} else if ((strokes - par) <= -2){
  return[1];
}


  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; rv:108.0) Gecko/20100101 Firefox/108.0

Challenge: Basic JavaScript - Golf Code

Link to the challenge:

also i changed the second return to return names[1] and it still doesnt work

The key is in the if, i tried to do this and get a bit confussed because i don’t know nothing about golf but the table in the instructions are saying you all you nee to know. In this case you overthink with

((strokes - par) <= -2)

What they want is: strokes are minus or equal that (par-2)?

There are a number of reasons why this challenge doesn’t pass:

  1. you can’t use a single = as a comparison operator. To test for equality you use == or for strict equality ===.
  2. Your function is incomplete as you have not accounted for all possible outcomes.
  3. Your strokes minus par comparison is a little confusing and shouldn’t be a <= comparison (should be ==). Simpler would be to subtract strokes from par and check if it equals 2.
  4. If you pass par 5 and strokes 4 to the function it’s not an eagle. It’s a birdie.

Im still having problems i rewrote the code but still not working


function golfScore(par, strokes) {
  // Only change code below this line
 if (strokes === 1) {
return names[0];
} else if (strokes === 2) {
return names[1];
} else if (strokes === 3) {
return names[2];
} else if (par === strokes) {
return names[3];
} else if (strokes === par + 1) {
return names[4];
} else if (strokes === par + 2) {
return names[5];
} else if (strokes >= par + 3) {
return names[6];

nevermind it didnt work because i forgot to close the bottom parenthesis