Basic JavaScript: Golf Code(Most nonsensical)

codePreformatted text

var 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 names[0];
  } else if (strokes <= par - 2) {
    return names[1];
  } else if (strokes == par - 1) {
    return names[2];
  } else if (strokes == par) {
    return names[3];
  } else if (strokes == par + 1) {
    return names[4];
  } else if (strokes == par + 2) {
    return names[5];
  } else if (strokes >= par + 3) {
    return names[6];
  }
  
  return "Change Me";
  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);

This is the most nonsensical code EVER!
For one I dont know why did they choose gold a sport that is boring and 99% of the World doesnt play.

The wierd part is how did the computer understand that assignment anyways, why where the Par argument given in ‘numbers’ while we used its relationship with strokes as a statement. That was very strange.
Why does strokes >=par+3 makes any sense to a human or a computer the goldScore function uses an argument and they are both numerical???
Also why strokes isnt equal to par?
Oh my,
anyway I cheated to get with this assignment and I am moving forward but it makes zero sense and the fact it is golf related topics doesnt make it any easier.
That said, thanks for everyone, I am learning very slowly but learning nonetheless.

FYI you can go to the next challenge without completing the current one, which I think is a better approach so that you can return later to the challenges you weren’t able to complete

In golf each hole has a par, which is the average number of hits needed to put the ball in the hole. The strokes is the actual number of hits the player needed, and the score is given as a comparison between the average number of hits and the actual number that the player needed
As such all the if statements are comparing strokes to par to give the score. Well, the first is the exception as making it in one stroke requires a special score!

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums

Like every sport I know anything about, golf is pretty nonsnesical. While the golf score provides a context for this particular challenge, you don’t actually have to know, understand, or care about golf to complete it. The only term I knew from golf before doing that challenge was “hole in one”.