title: how to add spaces between array items javascript
body: <p>I am a beginner at javascript so I appreciate any help/advice given.</p>
  
  <p>My issue here is that I'm trying to figure out how to add space between items in the times[] array which holds the values for showtimes for each movie object. I tried to split at the comma (",") but that isn't working. When I tried splitting at ("pm") that worked. I also figured out a way to add space in the showtimes values themselves, but I thought that there must be a better way to go about it. Any thoughts? thanks!</p>
  
  <pre><code>window.onload = init;
  
  
  function Movie(title, year, showtimes) { 
    this.title = title;
    this.year = year;
    this.showtimes = showtimes;
    }
  
    function init() {
      var darkKnight = new Movie("The Dark Knight Rises", "2012", ["1pm,", "2pm,", "3pm,"]);
      var takeThisWaltz = new Movie ("Take This Waltz", "2012", ["4pm", "5pm","6pm"]);
      var watchmen = new Movie("Watchmen", "2009", ["7pm","8pm","9pm"]); 
  
      var movieList = [darkKnight, takeThisWaltz, watchmen]
  
  
      for(var i = 0; i &lt; movieList.length; i++) { 
      var theObj = movieList[i];
      var times = [movieList[i].showtimes] 
        for(var j = 0; j &lt; times.length; j++) {
        var str = times[i];     
        } 
      makeResult();    }
  
  
      function makeResult() {             
      var list = document.getElementById("movieList"); 
      var li = document.createElement("li");          
      li.innerHTML = "title: " + movieList[i].title + " year: " + movieList[i].year + " showtimes: " + times[0].toString().split(",");
      list.appendChild(li); }
  
  
   }
  </code></pre>