Open JenMorgan opened 4 years ago
function extractCurrencyValue (str) { for (let i = 0; i < str.length - 1; i++) { if (!isNaN(parseInt(str[i]))) return parseInt(str.slice(i)); } return "There is no currency value provided"; } alert( extractCurrencyValue('the price is 300 USD'))