title: How do i acess a variable outside a function in javascript
body: <p>i want to access  const newdata outside a function</p>
  
  <pre><code>    function updateFields(response) {
          $("#FIELDSET").removeProp('disabled');
  
          const parser = new DOMParser();
          const xmlDoc = parser.parseFromString(response, "text/xml");
          const data = xmlDoc.getElementsByTagName("responses")[0].innerHTML;
          const rdata = data.split('//')[0]
          const payload = data.split(':1:1,')
              .map(x =&gt; x.split('='))
              .reduce((obj, x) =&gt; {
                  obj[x[0].replace(/\./g, '_')] = x[1];
                  return obj;
              }, {})
  
          const newdat="string";
  
  
          CO_CODE=payload.CO_CODE.split(':1:1')[0]
          const {AMOUNT, INT_RATE, TERM, FREQUENCY, REP_START_DATE, CUSTOMER_ID, INSTALMENT} = payload;
  
      }
  </code></pre>