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, strokes = 1) {
return "Hole-In-one!";
} else if (<= par - 2) {
return "Eagle";
} else if (par - 1) {
return "Birdie";
} else if (par) {
return "Par";
} else if (par + 1) {
return "Bogey";
} else if (par + 2) {
return "Double Bogey";
} else if (>= par + 3) {
return "Go Home";
}
return "Change Me";
// Only change code above this line
}
golfScore(4, 1);
here’s a link for the problem
the way they’ve asked this question is so confusing
Hi there, the condition in if statement is not . you should compare strokes with par
If you dont mind me asking how do I do that?
no, you can do like this if( strokes === 1) you return string hole in one and the condition for eagle should be strokes <= par -2
ok lemme try that so it should be like
(strokes <= par -2) returns “Eagle”
yes like that , then let me know
const 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 if (strokes = par + 3) {
return "Go Home";
}
return "Change Me";
// Only change code above this line
}
golfScore(4, 1);
Some of the results worked but some didn’t, what should i do?
= is an assignment operator, for checking equality use === operator
1 Like
these <= and >= operators are fine for conditions but not just =
const 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 if (strokes >= par + 3) {
return "Go Home";
}
return "Change Me";
// Only change code above this line
}
golfScore(4, 1);
This is the new code what should i change now?
“Hole in one” and “Go Home” are the only ones not returning
Check for typos. The text you are returning should match exactly what is asked for.
yes check for typos copy paste the text from the challenge. your “names” array has correct text in it
system
Closed
15
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.