Insert number after second character

I will receive a phone via json “4788289126”

I wanted a function that will identify that it is only 10 characters long and will insert a number 9 after the second character.

Your question sounds incomplete. You say that it should identify that it is only 10 characters long. What is supposed to happen if it is shorter or longer?

I managed to give a solution, but I appreciate your return

api automatically takes the number it will always come with 10 characters

I made this code there that worked perfectly

const nome = $item(0).$json["body"]["phone"];
let primeiraparte = nome.substr(0, 4);
let segundaparte = nome.substr(4,13);
let coloca9 = primeiraparte+9;
let numerocom9 = coloca9+segundaparte;
return [{json:{numerocom9 }}];