Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.



		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<title>Rock Paper Scissors</title>
		<link rel="stylesheet" type="text/css" href="my-styles.css">


		<h1>Rock Paper Scissors</h1>
		<button onclick="userChoose(rock)">Rock</button>
		<button onclick="userChoose(paper)">Paper</button>
		<button onclick="userChoose(scissors)">Paper</button>
		<p id="computerDisplay"></p>
		<h2 id="resultDisplay"></h2>

		<script type="text/javascript" src="my-scripts.js"></script>




                body {
	text-align: center;
	margin-top: 50px;


                //define html variables
var computerDisplay = document.getElementById("computerDisplay")
var resultDisplay = document.getElementById("resultDisplay")

//create user and computer
var user
var computer

//create choice prototype
function Choice(x, y) {
	this.choice= x; = y;

//create choices
var rock = new Choice("rock", "scissors");
var paper = new Choice("paper", "rock");
var scissors = new Choice("scissors", "paper");

//prepare computer choose function
var choices = [rock, paper, scissors]
function computerChoose(x){
	var index = Math.floor(Math.random() * x.length);
	computer = x[index];

//user chooses, causing computer to choose
function userChoose(choice){
	user = choice;
	computerDisplay.innerHTML = "Computer chose <b>"+computer.choice+"</b>";
	if(user.choice == computer.choice){
		resultDisplay.innerHTML = "Tie";
	} else if ( == computer.choice) {
		resultDisplay.innerHTML = "You win!";
	} else {
		resultDisplay.innerHTML = "You lose";