JSFiddle - React, Tailwind, and code Playground

by Robin van der Noord

HTML

the /* */ are there because otherwise the code would run when you'd open jsfiddle.net and that's annoying :/

JavaScript

/* function playGame() {
    var user1 = prompt("rock, paper, scissors");
    var user2 = prompt("rock, paper, scissors");
    if (user1 === user2) {
        alert("tie, try again!");
    }

    if (user1 === "rock") {
        if (user2 === "scissors") {
            alert("yay " + name1 + " wins with " + user1);
        } else if (user2 === "rock") {
            alert("tie...");
        } else {
            alert("yay " + name2 + " wins with " + user2);
        }
    } else if (user1 === "paper") {
        if (user2 === "rock") {
            alert("yay " + name1 + " wins with " + user1);
        } else if (user2 === "rock") {
            alert("yay " + name2 + " wins with " + user2);
        } else {
            alert("tie...");
        }
    } else if (user1 === "scissors") {
        if (user2 === "scissors") {
            alert("tie...");
        } else if (user2 === "paper") {
            alert("yay " + name1 + " wins with " + user1);
        } else {
            alert("yay " + name2 + " wins with " + user2);
        }
    } else {
        document.write("wut");
    }

    var playAgain = confirm("Play Again?");
    if (playAgain) {
        // just run the game again
        playGame();
    }
}

// ask for their names
var name1 = prompt("what is your name?");
var name2 = prompt("what is your name?");

// run the first game
playGame();

*/