cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation


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.

	<title>Score Keeper</title>
	<link rel="stylesheet" type="text/css" href="style.css">
	<h1><span id="p1Display">0</span> - to - <span id="p2Display">0</span></h1>
	<p>Playing to: <span>5</span></p>
	<input type="number" name="">
	<button id="p1">Player 1</button>
	<button id="p2">Player 2</button>
	<button id="reset">Reset</button> 

<script type="text/javascript" src="script.js"></script>
              var p1Button = document.querySelector("#p1");
var p2Button = document.getElementById("p2");
var resetButton = document.querySelector("#reset");
var p1Display = document.querySelector("#p1Display");
var p2Display = document.querySelector("#p2Display");
var numInput = document.querySelector("input");
var winningScoreDisplay = document.querySelector("p span");
var p1Score = 0;
var p2Score = 0;
var gameOver = false;
var winningScore = 5;

function buttonp1Click(){
	if(p1Score === winningScore){
		gameOver = true;
	p1Display.textContent = p1Score;
p1Button.addEventListener("click", buttonp1Click);  

p2Button.addEventListener("click", function(){
	if(p2Score === winningScore){
		gameOver = true;
	p2Display.textContent = p2Score;

resetButton.addEventListener("click", function(){

function reset(){
	p1Score = 0;
	p2Score = 0;
	p1Display.textContent = 0;
	p2Display.textContent = 0;
	gameOver = false;

//numInput can be changed to this. inside the function for example this.value
numInput.addEventListener("change", function(){
	winningScoreDisplay.textContent = numInput.value
	winningScore = Number(numInput.value);

Loading ..................