Basic JavaScript - Golf Code

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

const names = ["Hole-in-one!", "Eagle", "Birdie", "Par", "Bogey", "Double Bogey", "Go Home!"];

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

golfScore(5, 4);
console.log(golfScore(5, 2))

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Basic JavaScript - Golf Code

Link to the challenge:

Hello! What do you need help with? You didn’t describe your issue above…

Hi @swow2me !

Welcome to the forum!

The code you provided passes the tests.
If you have a question about the lesson, please tell us what you need help with.

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