SHARE
TWEET

Untitled

a guest Jun 18th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function result(command) {
  2.     let commands = {
  3.         upvote: () => this.upvotes++,
  4.         downvote: () => this.downvotes++,
  5.         score: () => {
  6.             let totalVotes = this.upvotes + this.downvotes;
  7.             const numberToAdd = Math.ceil(Math.max(this.upvotes, this.downvotes) * 0.25);
  8.             let reportUpVotes = totalVotes > 50 ? this.upvotes + numberToAdd : this.upvotes;
  9.             let reportDownVotes = totalVotes > 50 ? this.downvotes + numberToAdd : this.downvotes;
  10.             let totalScore = this.upvotes -  this.downvotes;
  11.             let majority = this.upvotes / totalVotes > 0.66;
  12.             let rating = '';
  13.             if (totalVotes < 10) {
  14.                 rating = 'new';
  15.             } else if (totalScore < 0) {
  16.                 rating = 'unpopular';
  17.             }else if (majority) {
  18.                 rating = 'hot'
  19.             } else if (reportUpVotes > 100 || reportDownVotes > 100) {
  20.                 rating = 'controversial';
  21.             }  else {
  22.                 rating = 'new';
  23.             }
  24.  
  25.             return [reportUpVotes, reportDownVotes, totalScore, rating];
  26.         }
  27.     };
  28.     return commands[command]();
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top