title: Javascript: TypeError: ... is not a constructor
body: <p>I have a TypeError problem:</p>
  
  <pre><code>function artist(name) {
      this.name = name;
      this.albums = new Array();
  
      this.addAlbum = function(albumName) {
          for (var i = 0; i &lt; this.albums.length; i++) {
              if (this.albums[i].name == albumName) {
                  return this.albums[i];
              }
          }
  
          var album = new album(albumName);
          this.albums.push(album);
  
          return album;
      }
  }
  
  function album(name) {
      this.name = name;
      this.songs = new Array();
      this.picture = null;
  
      this.addSong = function(songName, track) {
          var newSong = new songName(songName, track);
          this.songs.push(newSong);
  
          return newSong;
      }
  }
  </code></pre>
  
  <p>gives the following error:</p>
  
  <p><code>TypeError: album is not a constructor</code></p>
  
  <p>I can't find the problem. I read a lot of other posts, but I could not find a similar problem. Could it be that it's not allowed to create an object in another object? How I can solve this problem?</p>