Golf Code help to solve

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 (pa)
  return "Change Me";
  // Only change code above this line

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36.

Link to the challenge:

use if / else if chains to return different values in different scenarios

Have you thought about writing this out by hand to grasp it? That helps me. So in this challenge, you have a table of conditions that lead to an outcome.

The simplest is if strokes is == 1, then return “Hole-in-one!” You know that if they hit the ball and immediately get it in the hole, then the program is over. There’s no reason to test for the other cases. Maybe make that the first if statement? if (strokes == 1) {print the index of the array for hole in one} else {everything else};

As you go through the rest, think about the math relationship between strokes and par that leads to the conditions. strokes minus par = what? After that, change the language to javascript. So if strokes minus par is -3, print “Double Eage,” otherwise keep reading through the rest of the program.