Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.


  var artistName;
  var artistPop;
  var artistAlbumsURL;
  var artistAlbums = [];
  var artistAlbumsStr;
  var albumArray;
  var albumsArrays = [];
  var severalAlbumsURL;

  var albumID;
  var albumName;
  var albumReleased;
  var albumPop;
  var albumTracks = [];
  var trackID;
  var trackName;
  var trackPop;

  var albumTracksURL;
  var albumTracksIDs = [];

  function Artist (artistID, artistName, artistPop, artistAlbums) {
    this.artistID = artistID;
    this.artistName = artistName;
    this.artistPop = artistPop;
    this.artistAlbums = artistAlbums;

  function Album (albumID, albumName, albumPop, albumReleased, albumTracks) {
    this.albumID = albumID;
    this.albumName = albumName;
    this.albumPop = albumPop;
    this.albumReleased = albumReleased;
    this.albumTracks = albumTracks;

  // base of request URL
  var apiurl = "https://api.spotify.com";

  // artistID used as argument to get artistPop and artistAlbums
  var artistID;

  // Alice Cooper artistID for dev and testing
  // Eventually, GUI will receive input
  artistID = "3EhbVgyfGd7HkpsagwL9GS";

  // do I have to declare this outside build_artistURL? Same with other so-called global variables at top.
  var artistURL;

  function build_artistURL (artistID) {
    artistURL = apiurl + "/v1/artists/" + artistID;

  var rockstar = new Artist (artistID);
  rockstar.artistAlbums = [];

  function requestArtistInfo(artistURL){
    $.getJSON(artistURL, function(json){
      artistName = json.name;
      artistPop = json.popularity;
      rockstar.artistName = artistName;
      rockstar.artistPop = artistPop;


  function build_artistAlbumsURL (artistID) {
    artistAlbumsURL = apiurl + "/v1/artists/" + artistID + "/albums?offset=0&limit=50&album_type=album&market=US";

  function getArtistAlbums (artistAlbumsURL){
    $.getJSON(artistAlbumsURL, function(json){
      $.each(json.items, function (key, val){
        albumID = val.id;
  	  divideCombineAlbums (artistAlbums);

  function getAllAlbums(albumsArrays){
	  for (i=0; i<(albumsArrays.length); i++){
        var artistAlbumsStr = albumsArrays[i].join();
        build_severalAlbumsURL (artistAlbumsStr);
        getSeveralAlbums (severalAlbumsURL);

	function build_severalAlbumsURL (albumsString) {
	  severalAlbumsURL = apiurl + "/v1/albums?ids=" + albumsString + "&market=US";

  var albumsTracksArrays = [];

  function Track (trackID, trackName, trackPop) {
    this.trackID = trackID;
    this.trackName = trackName;
    this.trackPop = trackPop;

	function getSeveralAlbums (severalAlbumsURL) {
    var artistAlbumsObjects = [];
  	$.getJSON(severalAlbumsURL, function(json){
  		$.each(json.albums, function (albumIndex, album){
        albumID = album.id;
  			albumName = album.name;
  			albumPop = album.popularity;
  			albumReleased = album.release_date;
  			// console.log(albumName + ' = ' + albumPop + ' = ' + albumReleased);
  			albumX = new Album (albumID, albumName, albumPop, albumReleased);
  			albumX.albumTracks = [];
  			$.when($.each(album.tracks.items, function (trackIndex, track){
  				trackID = track.id;

  function getAlbumTracks(){
      build_albumTracksURL ();
      getSeveralTracks (albumTracksURL);

  function getSeveralTracks (albumTracksURL) {
    var albumTracks = [];
    $.getJSON(albumTracksURL, function(json){
      $.each(json.tracks, function (trackIndex, track){
        trackID = track.id;
        trackName = track.name;
        trackPop = track.popularity;
        // var trackAlbumName = track.album.name;
        trackX = new Track (trackID, trackName, trackPop);
      albumX.albumTracks = albumTracks;
      rockstar.artistAlbums.push (albumX);


  function build_albumTracksURL () {
    var albumToGet = albumTracksIDs.join();
    albumTracksIDs = [];
    albumTracksURL = apiurl + "/v1/tracks?ids=" + albumToGet + "&market=US";

  function divideCombineAlbums(artistAlbums){
    var artistAlbumsChunk;
    var x = Math.ceil((artistAlbums.length)/20);
    var firstAlbum = 0;
    for (i=0; i<x; i++){
      var lastAlbum = firstAlbum + 19;
      artistAlbumsChunk = artistAlbums.slice(firstAlbum, lastAlbum);
      firstAlbum += 19;

  function emptyTracks (){
	  albumTracks = [];
    albumsTracksArrays = [];

  build_artistURL (artistID)
  getArtistAlbums (artistAlbumsURL);


🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.