const rps = (p1, p2) => { if (p1 ==="rock" && p2 === "rock") return "Draw!" if (p1 ==="rock" && p2 === "paper") return "Player 2 won!" if (p1 ==="rock" && p2 === "scissors") return "Player 1 won!" if (p1 ==="paper" && p2 === "rock") return "Player 1 won!" if (p1 ==="paper" && p2 === "paper") return "Draw!" if (p1 ==="paper" && p2 === "scissors") return "Player 2 won!" if (p1 ==="scissors" && p2 === "rock") return "Player 2 won!" if (p1 ==="scissors" && p2 === "paper") return "Player 1 won!" if (p1 ==="scissors" && p2 === "scissors") return "Draw!" };
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