Trackster Project


#1

Hi I am finishing up on my Trackster project on Codecademy. I want to make my listeners number look nice by formatting it using numeral.js. I have tried it on my js code but it doesn’t work.

Trackster.renderTracks = function(tracks) {
  var $trackList = $("#track-list");

  $trackList.empty();

  for (var trackIndex = 0; trackIndex < tracks.length; trackIndex++) {
    var track = tracks[trackIndex];
    var mediumAlbumArt = track.image[1]["#text"];
    var formatListeners = numeral(track.listeners).format('0,0');

    var htmlTrackRow =
      '<div class="row track">' +
      '  <div class="col-xs-1 col-xs-offset-1 play-button">' +
      '    <a href="'+ track.url + '" target="_blank">' +
      '      <i class="fa fa-play-circle-o fa-2x"></i>' +
      '    </a>' +
      '  </div>' +
      '  <div class="col-xs-4">' + track.name + '</div>' +
      '  <div class="col-xs-2">' + track.artist + '</div>' +
      '  <div class="col-xs-2"><img src="' + mediumAlbumArt + '"/></div>' +
      '  <div class="col-xs-2">' + formatListeners + '</div>' +
      '</div>';

    $trackList.append(htmlTrackRow);
  }
};

Does anyone have any clue why it isn’t working correctly?

I am using http://numeraljs.com
and full project GitHub is https://github.com/tfan1210/Trackster

Thanks in advance.


#2

I couldn’t get your live site to function at all in terms of displaying tracks…

What about it doesn’t work? What’s it doing instead of what you want it to?


#3

The live site does work. I just tried it again, I would like to format the results of listeners so instead of display results like 12300 it would be like 12,300


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.