I am declaring a variable contactNumber
outside of a switch statement and then trying to assign it inside the switch statement. However, when it reaches the assignment, I get an error SyntaxError: Unexpected identifier
on the assignment line executed inside the switch statement
function helplineContactMessageForCountryCode(countryCode) {
var contactNumber = ''
switch (countryCode) {
case 'NG':
contactNumber = '234-01-772-2200'
break
case 'UG':
contactNumber = '0800-100-330'
break
case 'US'
contactNumber = '1-800-232-4636'
break
case 'ZA':
contactNumber = '0800-012-322'
break
default:
//Return empty string if no country code is found
return ''
}
return 'You can try calling the Toll-Free HIV and AIDS Helpline and speak to a human - ' + contactNumber
}
You are missing a :
after the "US" case
.
function helplineContactMessageForCountryCode(countryCode) {
var contactNumber = ''
switch (countryCode) {
case 'NG':
contactNumber = '234-01-772-2200';
break;
case 'UG':
contactNumber = '0800-100-330';
break;
case 'US':
contactNumber = '1-800-232-4636';
break;
case 'ZA':
contactNumber = '0800-012-322';
break;
default:
contactNumber = contactNumber;
break;
}
return 'You can try calling the Toll-Free HIV and AIDS Helpline and speak to a human - ' + contactNumber
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments