JSFiddle - React, Tailwind, and code Playground
HTML
<input id="input" value="25 million, 23 thousand, 943"></input>
<button id="convert">Convert</button>
<div id="result"></div>
JavaScript
var UNIT_SEPARATOR = ', '; // what separates the number parts (millions from thousands, ecc)
var VALUE_UNIT_SEPARATOR = ' '; // what goes between the value and the unit
var unitMap = {
billion:9,
million:6,
thousand:3,
'':0
}; // add as many units as you like
$('#convert').click(function () {
var number = $('#input').val();
var numberParts = number.split(UNIT_SEPARATOR);
var convertedNumber = 0;
for (var i = 0; i < numberParts.length; i++) {
var splitUnit = numberParts[i].split(' ');
var value = parseFloat(splitUnit[0]);
var exp = (splitUnit.length === 1) ? 0 : parseInt(unitMap[splitUnit[1]]);
var temp = value * Math.pow(10, exp);
convertedNumber += temp;
}
$('#result').text(convertedNumber);
});