JSFiddle - React, Tailwind, and code Playground
JavaScript
// Lets imagine this object is your req.param
reqParam = {
m1: 'email1',
m2: '',
m3: 'email3',
m4: 'email4',
someOther1: 'some other param',
m5: '',
m61: 'email6',
someOther: 'otherValue'
}
const emailTable = []
for (let key of Object.keys(reqParam)){
// check if it is email and if it has value
if(key.match(/^[m]+[0-9]*$/g) != null && reqParam[key] != ''){
emailTable.push(reqParam[key])
}
}
console.log(emailTable)