163 views
Function that forms a phone number from an array of digits
Task condition
It is necessary to implement a function that takes an array of 10 integers (each from 0 to 9) as input and returns a string representing these digits as a phone number. Example usage:
formatPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) // => returns "(123) 456-7890"
The resulting string must exactly match the specified pattern: an opening parenthesis, three digits, a closing parenthesis, a space, three digits, a hyphen, and the last four digits.