-
-
Save parzibyte/3f4e46e54a0a30959e3a521aa53b1eba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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