I am making a Jason API in Express and Node I am working this perfectly but I have the key in this expression I do not understand how to name the output. Even I have so far ...
for (req.body in var k) {if (req.body.hasOwnProperty (k)) {if (k ! = 'FormId' & Amp; amp; k! = 'First name' & amp; amp; k! = 'Last name' & amp; k! = 'Email' & amp; k! = 'Phone '& Amp; amp; k! =' Company '& amp; amp; k! K! =' Topic '& amp; amp; k! =' Message ') {additionalFields.push ({: req.body [k]}) ; }}} Console.log (additional files);
And the output is:
[{k: '$ 5000 - $ 10000'}, {k: ['business card', 'web design ',' Graphic design ']}]
Which is the most correct, but I want the name of the key instead of "K". I am new to javascript and reading myself as I go, so this will be a great lesson for me to remember in the future. Here's my desired result, if someone can help me get there, it would be great ...
[[Price range: '$ 5000 - $ 10000'}, { ServicesNeeded: ['business card', 'web design', 'graphic design']]]
Dynamic variable key-name should use bracket notation. Otherwise the name of the key is literally translated as k
. Try it out:
var obj = {}; Obj [k] = laxative [Ku]; AdditionalFields.push (obj);
Comments
Post a Comment