Help me in clearing error

Tell us what’s happening: i am not able to understand the error i am doing
i have wriiten correctly everything

  **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 == 4, strokes == 1){
return names[0]
} else if  (par == 4, strokes == 2){
return names[1]
}else if  (par == 5, strokes == 2){
return names[1]
}else if (par == 4, strokes == 3){
return names[2]
}else if  (par == 4, strokes == 4){
return names[3]
}else if  (par == 1, strokes == 1){
return names[0]
}else if  (par == 5, strokes == 5){
return names[3]
}else if (par == 4, strokes == 5){
return names[4]
}else if (par == 4, strokes == 6){
return names[5]
}else if (par == 4, strokes == 7){
return names[6]
}else if  (par == 5, strokes == 9){
return names[6]
} 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/89.0.4389.128 Safari/537.36.

Challenge: Golf Code

Link to the challenge:

this is not how you check two conditions at once
also, that will make a function that works only in specific cases, you should strive to make a function that works whatever the input

Look at the table given in the problem statement. For example, you return “Birdie” if the number of strokes is one less than the par. You don’t need to spell out individual cases like if par is 5 and strokes is 4, par is 4 and strokes is 3, and so forth. You just need to test if strokes is equal to par - 1.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.