Input array
var array = [
'name',
'"Mobile Number"',
'"mobile1,mobile2"',
'email2',
'Address',
'email21'
]
var matchkey = 'mobile1,mobile2'
res = res.map(function (value) {
if(value==matchkey){
return value+".string()"
}
else {
return value+".auto()"
}
})
Current Output from above code
[
'name.auto()',
'"Mobile Number".auto()',
'"mobile1,mobile2".auto()',
'email2.auto()',
'Address.auto()',
'email21.auto()'
]
Expected Ouptput;
[
'name',
'"Mobile Number.auto()"',
'"mobile1,mobile2.string()"',
'email2.auto()',
'Address.auto()',
'email21.auto()'
]
Note: I don't wish to eliminate double quotes inside single quotes as they are necessary for future processing