Golf Code what's the point?

Hey, I don’t get it Golf Code task reference, could explain me wha’ts the point in this task ??

It’s just an exercise in logical operations. You are supposed to compare two variables and depending on their difference you return different strings.

@ArielLeslie

Yeah I know but when I comparing both arguments it doesn’t work,
Example with with Hole-in-One is working,
I putted

If( stroke == 1) {
return names[0];
}

But when I comparing another one for example Eagle

else if ( strokes <= (par - 2)) {
return names[1];

It doesn’t work.

BTW Thnaks for reply

Hi @edi90r,

If( stroke == 1) {
return names[0];
}

I think the reason why this code didn’t work is because of your i in the “if” and your variable stroke should be strokes

You have errors.

If( stroke == 1) { // This contains multiple typos

Thanks @iamcris

I corrected on :slight_smile:

It will be better if you paste everything

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 (par - 2 >= strokes){
    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);

if ( strokes = 1 ){ // You still have an error here.

Could you give me a hint ? :slight_smile:
should I include par ??

the hint is here bud: https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-equality-operator/

1 Like

Okay thanks Guys ! I’m silly edi, really I didn’t notice this :confused: Thanks again

don’t be hard on yourself man. I am just like you. I make a lot of mistakes but remember we are all here to learn from each other. mistakes are great for our growth to become a better programmer.

happy coding my friend!

You could potentially have this issue, there are 2 Eagles- when I think it’s actually an albatross or just not supposed to even be there.