MovieMaker.js

Home   »   MovieMaker.js

function MovieMaker(name) {
 	var ticketsSold = 0;
  
  document.write(
    `

${name}

` ); var elem = document.getElementById(`Buyone-${name}`); elem.onclick = function() { ticketsSold++; }; var elem = document.getElementById(`Familypack-${name}`); elem.onclick = function() { ticketsSold += 5; }; return { name: name, ticketsSold: function() { return ticketsSold } }; } var movies = [ MovieMaker("Jocker"), MovieMaker("Last Chance Harvey"), MovieMaker("The same kind of diffrent as me") ]; setInterval(function(){ movies.forEach(function(movie) { console.log(movie.ticketsSold(), ' tickets sold for ', movie.name); }); }, 2000);

Leave a Reply

Your email address will not be published. Required fields are marked *