Reputation: 3
if (monthsResult2 === 1) {
monthsAppend = "month";
} else if (monthsResult2 > 1)
monthsAppend = "months";
} else {
monthsAppend = " ";
}
Can anyone tell me what the issue with the if/else statement is? I am currently getting the error:
Uncaught SyntaxError: Unexpected token else
But after looking at multiple examples I can't for the life of me see what I am doing wrong! Any help would be greatly appreciated!
Upvotes: 0
Views: 2176
Reputation: 351
Ya forgot a {
in your else if
if (monthsResult2 === 1) {
monthsAppend = "month";
} else if (monthsResult2 > 1) {
monthsAppend = "months";
} else {
monthsAppend = " ";
}
Upvotes: 2
Reputation: 7004
You forget the open of the curly brace {
in your else if
.
else if (monthsResult2 > 1)
^
}
Try this:
if (monthsResult2 === 1) {
monthsAppend = "month";
} else if (monthsResult2 > 1) {
monthsAppend = "months";
} else {
monthsAppend = " ";
}
Upvotes: 0