How do I get my 'for loop' to return the characters I am trying to push?

I am learning the fundamentals of JavaScript currently but am realizing there are definite gaps in my knowledge. I recently started attempting challenges on Codewars when this issue became much more apparent. My latest struggle has been attempting to get this ‘for loop’ to push characters into an array of numbers in order to format it like a phone number. As many different solutions as I have tried, none of them actually do what I am trying to accomplish. Any help figuring out exactly where I’m going wrong here and what holes are in my logic would be appreciated. My best attempt is this:

const createPhoneNumber = (phoneNumber) => {
    let formattedNumber = [];
    formattedNumber.push(phoneNumber)
    for (let i = 0; i < formattedNumber.length; i++) {
        if (formattedNumber[i] === 0) {
            formattedNumber.push('(')
        }
        if (formattedNumber[i] === 2) {
            formattedNumber.push(')')
        }
        if (formattedNumber[i] === 5) {
            formattedNumber.push('-')
        }
    }
    return(formattedNumber.toString());
}

console.log(createPhoneNumber(1234567890));

Hello.

Please write comments on the lines of your code so that we can understand what you want to achieve in each line. And give an example of the correct output for the input 1234567890.

As well as what @9509706156 said, after you push the phone number to formattedNumber, that array becomes:

[ 1234567890 ]

Which is only one element. If you want to get each number of its own, you’ll have to try splitting it up before putting it in the array.

Hello.
I saw the original assignment and it says that you should write a function that accepts an array of 10 integers. In the last line, where you call the function, it should look like:

createPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) // => returns "(123) 456-7890"

Since they want the output as a string, I don’t think we actually need another array.
We can create an empty string (our formattedNumber) and add each number inside the for loop with a string concatenation. We just have to check the positions where we need to add these special characters, and it’s done.

const createPhoneNumber = (phoneNumber) => {
  let formattedNumber = "";
  for (let i = 0; i < phoneNumber.length; i++) {
    if (i === 0) {
      formattedNumber += `(${phoneNumber[0]}`; // formattedNumber += '(' + phoneNumber[0];
    } else if (i === 2) {
      formattedNumber += `${phoneNumber[2]}) `; // formattedNumber += phoneNumber[2] + ') ';
    } else if (i === 5) {
      formattedNumber += `${phoneNumber[5]}-`; // formattedNumber += phoneNumber[5] + '-';
    } else {
      formattedNumber += phoneNumber[i];
    }
  }
  return formattedNumber;
}

console.log(createPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]));