Sí, he escrito un jQuery plug-in called Word Math que se hizo para este propósito exacto.
Para el ejemplo en su pregunta, sólo puede copiar y pegar este código
alert($.wordMath("four thousand and three").add("seven thousand and twenty nine"));
//alerts "eleven thousand thirty two"
y listo! Has realizado algunas palabras matemáticas.
matemáticas de la palabra también puede hacer la conversión de números JavaScript para palabras y viceversa:
$.wordMath.toString(65401.90332)
// sixty five thousand four hundred one and nine tenths and three thousandths and three ten thousandths and two hundred thousandths
$.wordMath("three million four hundred and sixty seven thousand five hundred and forty two").value
// 3467542
You can read more about how to use the Word Math plugin on its readme page
EDIT: ahora hay una versión de Word matemáticas que no depende de jQuery. Para usarlo, debe descargar el archivo wordMath.vanilla.min.js
en el repositorio de gitHub en lugar del archivo wordMath.jquery.js
.
El uso de la versión jQuery-less es exactamente igual a la versión de jQuery, excepto que no necesita el prefijo $.
en las llamadas. En otras palabras, en lugar de hacer
$.wordMath("fifteen").add("eighteen")
debe en su lugar escribir
wordMath("fifteen").add("eighteen")
sí, probablemente lo haya. ¿Qué has intentado? –
Intenté preguntarle SO ... aún no tuve suerte. – Daniel
jaja ... brillante –