Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created February 20, 2023 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/3f4e46e54a0a30959e3a521aa53b1eba to your computer and use it in GitHub Desktop.
Save parzibyte/3f4e46e54a0a30959e3a521aa53b1eba to your computer and use it in GitHub Desktop.
const separarCadenaSiSuperaLongitud = (cadena, maximaLongitud, separador) => {
let resultado = "";
let indice = 0;
while (indice < cadena.length) {
const pedazo = cadena.substring(indice, indice + maximaLongitud);
indice += maximaLongitud;
resultado += pedazo;
if (indice < cadena.length) {
resultado += separador;
}
}
return resultado;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment