Last active
March 14, 2018 02:57
-
-
Save parzibyte/ed804041507156da9a8c62dc0c9bfd3e 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
$scope.comenzar = textoOriginal => { | |
if (!textoOriginal) return; | |
$scope.haComenzado = true; | |
let textoComoArreglo = textoOriginal | |
.replace(/[áéíóúñ]/g, coincidencia => { | |
return { | |
á: "a", | |
é: "e", | |
í: "i", | |
ó: "o", | |
ú: "u", | |
ñ: "n" | |
}[coincidencia]; | |
}) | |
.replace(/\W+/g, " ") | |
.toLowerCase() | |
.split(" "), | |
contador = 0, | |
textoModificado = []; | |
textoComoArreglo.forEach(palabra => { | |
if ( | |
$scope.deberiaBorrarEstaPalabra() && | |
contador < $scope.minimaSeparacionEntreInputs | |
) { | |
contador++; | |
textoModificado.push({ | |
palabraOriginal: palabra, | |
palabraIntroducida: "" | |
}); | |
} else { | |
textoModificado.push({ | |
palabra: palabra | |
}); | |
if (contador > 0) contador--; | |
} | |
}); | |
$scope.textoModificado = textoModificado; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment