Tell us what’s happening:
Describe your issue in detail here.
SyntaxError: unknown: Missing semicolon. (4:16)
2 | function golfScore(par, strokes) {
3 | if (strokes == 1) {
4 | return names{0}
| ^
5 | } else if (strokes <= par - 2) {
6 | return names{1}
7 | } else if (strokes == par - 1) {
**Your code so far**
var names = ["Hole-in-one!", "Eagle", "Birdie", "Par", "Bogey", "Double Bogey", "Go Home!"];
function golfScore(par, strokes) {
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}
}
}
// Change these values to test
console.log(golfscore(5,4));
/*
Strokes Return
1 "Hole-in-one!"
<= par - 2 "Eagle"
par - 1 "Birdie"
par "Par"
par + 1 "Bogey"
How do I fix this?
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36 Edg/92.0.902.84
Challenge: Golf Code
Link to the challenge:
jeromeross29:
return names{0}
What do you think you’re referring to with the curly braces here? Javascript doesn’t understand your syntax.
To the names of the pars & strokes
Now it’s saying unterminated comment how do I fix that
Is your comment, the /*
, closed with a */
somewhere?
I have it at the bottom where it says strokes & returns above strokes and that would be the / *
Now it’s telling me to return the strings in which I’ve already done
I think you’ll need to post your updated code.
How do I do that do u have a phone number I can reach u at
zaklina
August 31, 2021, 6:36pm
#10
console.log(golfscore(5,4));
and your function is golfScore
jeromeross29:
How do I do that
In the FCC editor (which is what you are typing these messages in) you wrap your code with three backticks on a single line, then your code below those backticks, then three backticks again on a line following your code. Or you can click the </>
button in this editor and it will add the backticks for you and you just copy/paste in between them.
zaklina
August 31, 2021, 6:46pm
#12
jeromeross29:
var names = ["Hole-in-one!", "Eagle", "Birdie", "Par", "Bogey", "Double Bogey", "Go Home!"];
function golfScore(par, strokes) {
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}
}
}
// Change these values to test
console.log(golfscore(5,4));
/*
Strokes Return
1 "Hole-in-one!"
<= par - 2 "Eagle"
par - 1 "Birdie"
par "Par"
par + 1 "Bogey"
How do I fix this?
MOD EDIT: SOLUTION REDACTED
output is : Birdie
1 Like
Dude (generic term), I don’t think they want us just posting answers. We try to gently guide them to solving the problem.
1 Like
zaklina
August 31, 2021, 6:49pm
#14
It is not the answer he got to do a lot
thet is fixing his err…
I got it I Figured it out thanks guys
1 Like
Sometimes it is useful, for educational understanding, to compare a “before and after”. Seems to me this is the intent.
And yes, the after catches those things i was pointing out - but for educating, consider throwing in inline comments noting what you’ve changed.
In all though, solid support. I appreciate you!
zaklina
August 31, 2021, 8:16pm
#19
When someone pushes your wheel, it’s no big deal. Sometimes the more you look at it, the more you don’t see the mistake.
sorry. . .
1 Like
Lol I’m telling you, you’re fine. You did exactly right. I truly do appreciate you, and we as a community are better with you in.
No sorry. You do well.
1 Like