title: I am trying to modify server side js. which takes an json file as input and render the data to produce html file.
body: <p>Attached code takes json as input and i am trying to render data using script so that it comes in a proper format.</p>
  
  <p>we need to modify "json to html.txt" server-side js, so that the output in html from the input json .</p>
  
  <p>attached image shows the output at right side.this output must be in format.<a href="https://i.stack.imgur.com/8cH5w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8cH5w.png" alt="second image shows the required format"></a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  
  
  
  &lt;p id="demo"&gt;&lt;/p&gt;
  
  &lt;script&gt;
  
  var statement, i, j, x = "";
  statement = {
  "Financial statement:":
  ["NetIncomeLoss = ","- NetIncomeLossAttributableToNoncontrollingInterest","+ ProfitLoss = ","  + IncomeLossFromDiscontinuedOperationsNetO...","  + IncomeLossFromContinuingOperationsInclud... = ","    + apd_IncomeLossFromContinuingOperationsBeforeTaxes = ","      + OperatingIncomeLoss = ","        + SalesRevenueNet","        - CostOfGoodsAndServicesSold","        - SellingGeneralAndAdministrativeExpense","        - ResearchAndDevelopmentExpense","        - RestructuringCharges","        + apd_OtherIncomeExpenseNet","      + IncomeLossFromEquityMethodInvestments","      - InterestExpense","    - IncomeTaxExpenseBenefit","EarningsPerShareBasic = ","+ IncomeLossFromContinuingOperationsPerBasicShare","+ IncomeLossFromDiscontinuedOperationsNetOfTaxPerBasicShare","EarningsPerShareDiluted = ","+ IncomeLossFromContinuingOperationsPerDilutedShare","+ IncomeLossFromDiscontinuedOperationsNetO..."],
  "2009-12-31":[251.8,5,256.8,0,256.8,340.3,345,2173.5,1568.6,244.1,27.2,0,11.4,26.9,31.6,83.5,1.19e-06,1.19e-06,0,1.16e-06,1.16e-06,0],"2008-12-31":[68.6,5,73.6,-21.4,95,102.1,114.1,2195.3,1629.7,247,33.2,174.2,2.9,24.5,36.5,7.1,3.3e-07,4.3e-07,-1e-07,3.2e-07,4.2e-07,-1e-07]
  }
  
  var spaceCount=[];
  var financialStatement=[];
  
  
   var otherColumns = [];
    var output = '&lt;table class="table" style="width:100%;"&gt;&lt;tr&gt;';
    Object.keys(statement).forEach(function (key, i) {
      output += '&lt;th&gt;&lt;pre&gt;' + key + '&lt;/pre&gt;&lt;/th&gt;';
      if (i &gt; 0){
        otherColumns.push(key);
      }
    });
    output += '&lt;/tr&gt;';
  
    statement[Object.keys(statement)[0]].forEach(function(val, i){
      var total = false;
      if (val.indexOf('=') &gt; -1){
        total = true;
      }
     
      var printValue = '&lt;td&gt;&lt;pre&gt;' + val + '&lt;/pre&gt;&lt;/td&gt;';
      if (total){
        printValue = '&lt;td&gt;&lt;pre style="font-weight: bold;text-decoration: underline;"&gt;' + val + '&lt;/pre&gt;&lt;/td&gt;';
      }
      otherColumns.forEach(function(key, j){
        if (total){
          printValue += '&lt;td&gt;&lt;pre style="font-weight: bold;text-decoration: underline;"&gt;' + statement[key][i] + '&lt;/pre&gt;&lt;/td&gt;';
        }
        else
  {
          printValue += '&lt;td&gt;&lt;pre&gt;' + statement[key][i] + '&lt;/pre&gt;&lt;/td&gt;';
        }
      });
      output += printValue + '&lt;/tr&gt;';
    });
    output += '&lt;/table&gt;';
   
  document.getElementById("demo").innerHTML = output;
  
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>