I am trying to add a function to the global String object by doing the following:
function repetirCaracteres() {
String.prototype.repeatCharacters = function(palabra){
const letras = palabra.split('')
const repetir = letras.map(letras => letras.repeat(2))
let letrasRepetidas = repetir.join('');
return letrasRepetidas;
}
}
repetirCaracteres()
I want to do a function that receives a string and each character of the string is repeated twice.
Logic seems ok to me but for some reason i have the following error:
String prototype is read only, properties should not be added.