Untitled
// Live Debate Timer with Audience Interaction class DebateArena { constructor(topic, debater1, debater2) { this.topic = topic; this.debaters = [debater1, debater2]; this.timer = 180; // 3 minutes per round this.audienceVotes = { debater1: 0, debater2: 0 }; } startDebate() { const debateInterval = setInterval(() => { this.timer--; if (this.timer <= 0) { clearInterval(debateInterval); this.declareWinner(); } }, 1000); } audienceVote(debater) { this.audienceVotes[debater]++; } declareWinner() { const winner = this.audienceVotes.debater1 > this.audienceVotes.debater2 ? this.debaters[0] : this.debaters[1]; console.log(`${winner} wins the debate on ${this.topic}!`); } } // Example Usage const debate = new DebateArena("Remote work vs. office work", "Alice", "Bob"); debate.startDebate();
Leave a Comment