JSFiddle - React, Tailwind, and code Playground

by Justin

HTML

<script src="https://code.jquery.co\m/jquery-2.2.4.min.js"></script>
<div class="comments"></div>

JavaScript

var FanVideo = {
			comments : {
				5 : 'First Comment',
				24 : 'Second Comment',
				35 : 'Third Comment',
				43 : 'Fourth Comment'
			},
			_comments : {},
			init : function() {
				var self = this;
        var x = 0;
        this._comments = $.extend({}, this.comments);
        setInterval(function() {
        	
        	self.checkComment(x);
          x+5;
        }, 5000)
			},
			setVideo : function(videoObj) {
				self.resetComments();
			},
			_checkComment : function(time) {
				for( var key in this._comments) {
					if(key < time) {
						$('.comments').append('<p>' + this._comments[key] + '</p>');
						delete this._comments[key];
					}
				
				}
			}, 
			resetComments : function() {
				this._comments = $.extend({}, this.comments);
			}
		};

FanVideo.init();