Answers for "Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number."

1

Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number.

function createPhoneNumber(numbers){
  var format = "(xxx) xxx-xxxx";
  
  for(var i = 0; i < numbers.length; i++)
  {
    format = format.replace('x', numbers[i]);
  }
  
  return format;
}
Posted by: Guest on September-29-2020
1

Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number.

function createPhoneNumber(numbers){
  var format = "(xxx) xxx-xxxx";
  
  for(var i = 0; i < numbers.length; i++)
  {
    format = format.replace('x', numbers[i]);
  }
  
  return format;
}
Posted by: Guest on September-29-2020

Code answers related to "Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number."

Code answers related to "Javascript"

Browse Popular Code Answers by Language