How does this work??

Tell us what’s happening:

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 (stroke == 1) {
return 'Hole-in-one!';
} else if (stroke==2 &&par<=2){
return "Eagle";
}else if (stroke==3 &&par <=3){
return 'Birdie';
}else if (stroke ==4 && par <=4){
return 'Par';
}else if (stroke ==5 && par <=5){
return 'Bogey';
}else if (stroke ==6 && par <=6){
return 'Double Bogey';
}else{
return 'Go Home';
}
// Only change code above this line
}

golfScore(5, 4);

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 9; SM-N950F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.136 Mobile Safari/537.36.

Challenge: Golf Code

Link to the challenge:

Hello there,

Could you please edit your post to include information in the Tell us what’s happening section. Your title of “How does this work??” does not help us help you, because your code does not work.

Are you looking for help with the understanding of the code? Or, are you looking for help with completing the challenge?

The more information you give us, the more likely we will be able to help.

1 Like