Created
February 21, 2020 06:26
-
-
Save parzibyte/523e7dc2c91257250babf97c82800bf1 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 agregarCaracter = (cadena, caracter, pasos) => { | |
let cadenaConCaracteres = ""; | |
const longitudCadena = cadena.length; | |
for (let i = 0; i < longitudCadena; i += pasos) { | |
if (i + pasos < longitudCadena) { | |
cadenaConCaracteres += cadena.substring(i, i + pasos) + caracter; | |
} else { | |
cadenaConCaracteres += cadena.substring(i, longitudCadena); | |
} | |
} | |
return cadenaConCaracteres; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment