Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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.


Save Automatically?

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.


                <!DOCTYPE html>
<html lang="en">
	  <meta charset="UTF-8">
	  <meta name="viewport" content="width=device-width, initial-scale=1.0">
	  <meta http-equiv="X-UA-Compatible" content="ie=edge">
	  <link rel="stylesheet" href="styles.css">
	  <script src="script.js" defer></script>
	  <div class="selections">
	    <button class="selection" data-selection="rock">✊</button>
	    <button class="selection" data-selection="paper">✋</button>
	    <button class="selection" data-selection="scissors">✌</button>
	  <div class="results">
	      <span class="result-score" data-your-score>0</span>
	    <div data-final-column>
	      <span class="result-score" data-computer-score>0</span>
	    <!-- <div class="result-selection winner">✊</div>
	    <div class="result-selection">✌</div> -->


                body {
  background-color: #CCC;

.selections {
  display: flex;
  justify-content: center;

.selection {
  background: none;
  border: none;
  outline: none;
  cursor: pointer;
  font-size: 2rem;
  transition: 100ms;

.selection:hover {
  transform: scale(1.2);

.results {
  margin-top: 1rem;
  display: grid;
  justify-content: center;
  grid-template-columns: repeat(2, 1fr);
  justify-items: center;
  align-items: center;

.result-score {
  margin-left: .1rem;
  font-size: .5rem;
  color: #333;

.result-selection {
  opacity: .5;

.result-selection.winner {
  opacity: 1;
  font-size: 1.5rem;


                const selectionButtons = document.querySelectorAll('[data-selection]')
const finalColumn = document.querySelector('[data-final-column]')
const computerScoreSpan = document.querySelector('[data-computer-score]')
const yourScoreSpan = document.querySelector('[data-your-score]')
const SELECTIONS = [
    name: 'rock',
    emoji: '✊',
    beats: 'scissors'
    name: 'paper',
    emoji: '✋',
    beats: 'rock'
    name: 'scissors',
    emoji: '✌',
    beats: 'paper'

selectionButtons.forEach(selectionButton => {
  selectionButton.addEventListener('click', e => {
    const selectionName = selectionButton.dataset.selection
    const selection = SELECTIONS.find(selection => === selectionName)

function makeSelection(selection) {
  const computerSelection = randomSelection()
  const yourWinner = isWinner(selection, computerSelection)
  const computerWinner = isWinner(computerSelection, selection)

  addSelectionResult(computerSelection, computerWinner)
  addSelectionResult(selection, yourWinner)

  if (yourWinner) incrementScore(yourScoreSpan)
  if (computerWinner) incrementScore(computerScoreSpan)

function incrementScore(scoreSpan) {
  scoreSpan.innerText = parseInt(scoreSpan.innerText) + 1

function addSelectionResult(selection, winner) {
  const div = document.createElement('div')
  div.innerText = selection.emoji
  if (winner) div.classList.add('winner')

function isWinner(selection, opponentSelection) {
  return ===

function randomSelection() {
  const randomIndex = Math.floor(Math.random() * SELECTIONS.length)
  return SELECTIONS[randomIndex]