swati-jagtap / javascript-practice

0 stars 0 forks source link

12.1.1--Calculate the total annual income of the person from the following text. #144

Open swati-jagtap opened 3 years ago

swati-jagtap commented 3 years ago

//12.1.1--Calculate the total annual income of the person from the following text. //‘He earns 4000 euro from salary per month, //10000 euro annual bonus, 5500 euro online courses per month.’


let txt="He earns 4000 euro from salary per month, 10000 euro annual bonus, 5500 euro online courses per month."
let s= /\d+/g;               //  \d=contains digit ,+=1 or more  times
let salary=txt.match(s);
console.log(salary);
var total=0;
var a=salary.forEach((d)=>{
total=total+(parseInt(d));
})
console.log(total);

image