const rps = (p1, p2) => { if (p1 === p2) return "Draw!"; var rules = {rock: "scissors", paper: "rock", scissors: "paper"}; if (p2 === rules[p1]) { return "Player 1 won!"; } else { return "Player 2 won!"; } };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter