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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

				%h1 Tic Tac Toe
						%p#alert1 'X' WINS!
						%p#alert2 'O' WINS!
						%p#alert3 Already selected!

							%li#one{:value => "0"}
							%li#four{:value => "3"}
							%li#seven{:value => "6"}
							%li#two{:value => "1"}
							%li#five{:value => "4"}
							%li#eight{:value => "7"}
							%li#three{:value => "2"}
							%li#six{:value => "5"}
							%li#nine{:value => "8"}
				%button#reset Reset
	%p Made with love, by Pilar. 2017.
              $color1: rgb(249,251,250);
$color2: rgb(115,201,202);
$color3: rgb(60,128,151);
$color4: rgb(213,231,231);
$color5: rgb(108,24,109);

body {
	text-align: center;
	background: linear-gradient($color2, $color5);
	color: $color1;
	min-height: 900px;

.header {
	margin: 40px 0 20px 0;
	h1 {
		font-size: 100px;
		font-family: Avenir, sans-serif;

.main {
	width: 100%;
	max-width: 400px;
	margin: auto;
	@media screen and (min-width: 400px) {
		.col-sm-4 {
		width: 33.33%;
	ul {
		list-style: none;
		padding-left: 0;
		li {
			height: 110px;
			margin: 30px 0;
			background-color: $color4;
			border: 10px solid $color3;
			color: $color2;
			font-size: 60px;

	#alert1, #alert2, #alert3 {
		display: none; /* Display only when game is over */
		font-size: 28px;
		background-color: $color1;
		padding: 10px;
		border: 10px solid $color4;
		border-radius: 5px;
		color: $color5;
	#reset {
		font-size: 28px;
		width: 200px;
		background-color: $color1;
		border: 5px solid $color4;
		border-radius: 5px;
		color: $color5;
		margin-top: 20px;

.footer {
	margin: 50px;

	var turns = 0;
	var checkWinner;
	var xCombo = [];
	var oCombo = [];
	var possibleWinCombos = [
		[0, 1, 2],
		[0, 3, 6],
		[0, 4, 8],
		[1, 4, 7],
		[2, 4, 6],
		[2, 5, 8],
		[3, 4, 5],
		[6, 7, 8]
	// When O clicks on box, 0 should be aded.
	// When X clicks on box, X should be added.
	// Those turns must be added to an array =>
	// xCombo = X's turns
	// oCombo = O's turns
		var alreadySet = $(this).hasClass('set');

		if (alreadySet === true) {
			turns + 0;
		}	else {
			turns++; // alternate turns and add X or O to box
		if (turns % 2 === 0 && !alreadySet) {
			$(this).text('X'); // all even-numbered turns belong to X
			xCombo.push(parseInt($(this).val())); // Push the value of selected box into xArray
		} else if (turns % 2 === 1 && !alreadySet) {
			$(this).text('0'); // all odd-numbered turns belong to O
			oCombo.push(parseInt($(this).val())); // Push the value of selected box into oArray
		// If the intersection of one of the possibleWinCombo[i] arrays matches xCombo or oCombo
		// show the appropriate alert
		for(var i=0; i<possibleWinCombos.length; i++) {

			if (possibleWinCombos[i].length === _.intersection(xCombo, possibleWinCombos[i]).length) {
			} else if (possibleWinCombos[i].length === _.intersection(oCombo, possibleWinCombos[i]).length) {
	}); // end of click function
	// Clicking on the Reset button should reset the board
	// Boxes can be selected again => remove 'set' class
	// X/O will be replaced with empty string
	// Arrays are reset
		turns = 0;
		xCombo = []; 
		oCombo = [];
		// if game is already over
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.