Created
January 31, 2019 17:12
-
-
Save parzibyte/88c5ce2492295b45046fbe92bb4711d4 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 inputNumero = document.querySelector("#inputNumero"), | |
botonConvertir = document.querySelector("#botonConvertir"), | |
salida = document.querySelector("#salida"); | |
// Escuchar el click del botón | |
botonConvertir.addEventListener("click", function () { | |
// Obtener valor que hay en el input | |
let valor = parseFloat(inputNumero.value); | |
// Simple validación | |
if (!valor) return alert("Escribe un valor"); | |
// Obtener la representación | |
let letras = numeroALetras(valor, { | |
plural: "PESOS", | |
singular: "PESO", | |
centPlural: "CENTAVOS", | |
centSingular: "CENTAVO" | |
}); | |
// Y a la salida ponerle el resultado | |
salida.innerText = letras; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment