title: The function prints the days of the week(week.name) which have the highest traffic(week.traffic). Can you give me an alternate logic
body: <p>in the function below an array of objects is passed to the function. The object has 2 attributes: name and traffic. I am writing those days of week which have highest traffic to the console.</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-js lang-js prettyprint-override"><code>function mostPopularDays(week) {
  
    var Days = [];
  
    if (week == null || week.length == 0) {
      return null;
    }
  
    var max = week[0].traffic;
  
    var j;
    var k[];
  
    for (i = 1; i &lt; week.length; i++) {
      if (week[i].traffic &gt; max) {
        max = week[i].traffic;
        j = i;
      } else if (week[i].traffic == max) {
        j = i;
        k.push(i);
  
      }
  
    }
    if (j != k[k.length - 1]) {
      Days.push(week[j].name)
      console.log(Days[0]);
    } else {
  
      for (i = 0; i &lt; k.length; k++) {
        Days.push(week[(k[i])].name);
        cosole.log(Days[i]);
      }
      Days[k.length] = week[j].name;
      console.log(Days[k.length]);
  
    }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Argument passed to the function is an array of objects. I am comparing values based on objects.traffic and printing those object.names which have highest traffic.</p>