How to Format the Phone Number with dash

I run into the issue where the phone number field sent over with 0 and true phone number.

How could I ask to format this when the phone number field 0 to convert into this format 000-000-0000 and if the phone number is 9723106792 convert into 972-310-6792.

Below is what I have for the dash to added in but I cannot get the 0 for convert.

var field, result = “”;

field = record.fields[“HPhone”];

result=result.slice(0,3)+“-”+result.slice(3,6)+“-”+result.slice(6,10);

results.html(result);

var field, result = “”;

field = record.fields[“HPhone”];

if(field == 0) {

field = ‘0000000000’

}

result=result.slice(0,3)+“-”+result.slice(3,6)+“-”+result.slice(6,10);

results.html(result);

var field, result = “”;

I get error of missing after statement could you give more specific on code. Thank you.

field = record.fields[“HPhone”];

if(field == 0) {

field = ‘0000000000’}

result=result.slice(0,3)+“-”+result.slice(3,6)+“-”+result.slice(6,10);

results.html(result);

var field, result = “”;

field = record.fields[“HPhone”];

if(field == ‘0’) {

field = ‘0000000000’

}

result=field.slice(0,3)+“-”+field.slice(3,6)+“-”+field.slice(6,10);

results.html(result);

No does not work I have the same error message.

var field, result = “”;

field = record.fields[“HPhone”];

if(field == ‘0’) {

field = ‘0000000000’

}

result=field.slice(0,3)+“-”+field.slice(3,6)+“-”+field.slice(6,10);

results.html(result);

Please write the exact error…

“missing; after statement”

var field, result = “”;

field = record.fields[“HPhone”];

if(field == ‘0’) {

field = ‘0000000000’;

}

result=field.slice(0,3)+“-”+field.slice(3,6)+“-”+field.slice(6,10);

results.html(result);