Exercise of Golf Code JavaScript 122

I resolved this problem on another way… I used the “%”
if (strokes === 1){
return names[0];
}else if(par === strokes){
return names[3];
}else if(strokes <= par -2){
return names[1];
}else if(par > strokes){
return names[2];
}else if(par < strokes && strokes === 5){
return names[4];
}else if(strokes % par <=2){
return names[5];
}else{(par < strokes+2)
return names[6];
}

don’t do this, you are hardcoding a number, instead you need to have your code work for any possible input

1 Like