title: Passing Dynamic value inside Object which has array
body: <p>I have the following code I need to pass a dynamic value
  (for eg - Message: 'DP' Missing stamp in the header)</p>
  <p>In Error object with the Message field, i need to add dynamic value. What is the correct way to pass dynamic values?</p>
  <pre><code>var Error =
      {
          value:
          [
              { Code: 'Error1', Message: &quot;Missing stamp in header&quot; }
  
          ]
      }
  </code></pre>
  <pre><code>function ErrorCode(erCode) {
      var err = serviceErrors.errors.filter(function (er) {
          return er.Code == erCode
      });
  
     
  }
  </code></pre>
  <pre><code>function validateRequestHeaders(req) {
      var Error = { value: [] };
      return new Promise(function (resolve, reject) {
              if(req.header(&quot;stamp&quot;).toLowerCase() !== 'dp'){
                  Error.value.push(ErrorCode(&quot;Error1&quot;));
              }
          }
  
          resolve(Error);
  
      })
  }
  </code></pre>