'Why can't I iterate through an array in C++ and push_back items to a string? [duplicate]

I am sure there is a better way of doing this, but right now I'm stuck on why it doesn't work. I am very new at coding... and have been Googling for an hour trying to figure it out, and just can't. What am I doing wrong?

This is a Codewars challenge. One comment about the challenge said this:

"I didnt realize that I knew nothing about const keyword. Spent most of the time figuring out why I couldn't iterate through it or assign it to a string variable."

Maybe that's my problem too?

#include <iostream>
#include <string>

using namespace std;

std::string createPhoneNumber(const int arr[10]){
    
    string number;

    number.push_back('(');
    for (int i = 0; i < 2; i++) {
      number.push_back(arr[i]);
    }
    number.push_back(')');
    number.push_back(' ');
    for (int i = 3; i < 5; i++) {
      number.push_back(arr[i]);
    }
    number.push_back('-');
    for (int i = 6; i < 9; i++) {
      number.push_back(arr[i]);
    }

 return number;
}

int main() {
  int arraySend[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
  
cout << createPhoneNumber(arraySend);

return 0;
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source