Thursday, 27 April 2017

How to Remove string after string replace

For that code below the output of ins (lets assume the value of keys are summer, spring, fall, winter) is:

['req.body.summer, req.body.spring, req.body.fall, req.body.winter']

What i want is remove the string after the replace command, so i can insert it to my SQLite query. So the output must be:

[req.body.summer, req.body.spring, req.body.fall, req.body.winter]

Im just new into programming so please bear with me. Thank you!

var arr = '';

Object.keys(input).forEach(function(key) {
  arr += 'req.body.' + key + ', ';
});

var ins = [arr.replace(/,\s*$/, '')];

console.log(ins);



via John Carlo Velasquez

No comments:

Post a Comment