Write a script that inputs a telephone number as a string in the form (555)555-5555. The script should use String method split to extract the area code as a token, the first three digits of the phone number as a token and the last four digits of the phone number as a token. Display the area code in one text field and the seven-digit phone number in another text field.
1
Expert's answer
2011-07-19T10:17:36-0400
var p=window.prompt("Enter the phone in the form (XXX)XXX-XXXX",""); var code=p.split(")")[0].split("(")[1]; var p1=p.split(")")[1].split("-")[0]; var p2=p.split(")")[1].split("-")[1]; document.write(""); document.write("Code: "); document.write("Phone: "); document.write("");
Comments
For the above code the output is not generating...need help
Leave a comment