this is my code
function createPhoneNumber(numbers)
{
const phonelimit = [10]
for(var i = 0; i < 10; i++)
{
var j = i + 1
if (i == 9)
{
j -= 10
}
phonelimit[i] = j
}
var phoneNumber = "(" + phonelimit[0] + phonelimit[1] + phonelimit[2] + ") " + phonelimit[3] + phonelimit[4] + phonelimit[5] + "-" + phonelimit[6] + phonelimit[7] + phonelimit[8] + phonelimit[9])
return phoneNumber
}
my problem is that i am using a site called codehs for my highschool Java + javascript
and it only will allow me to submit it if it outputed using a return not a causal console.log
so some how i need to put all this junk that makes the phone number string into a variable then return the variable
I tried to do multiple toString() methods to create the whole format of the phone number thing with the numbers one variable but they didn't work
I fixed this by using the numbers variable and instead of j, I used the variable numbers and changed how the variable is returned