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 is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.


    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Memory Game</title>
    <script src="js/test.js"></script>
<link rel="stylesheet" href="css/style.css">
    <link href=',700,300' rel='stylesheet' type='text/css'>

var memory_array = ["A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F", "G", "G", "H", "H", "I", "I", "J", "J", "K", "K", "L", "L"];
var memory_values = [];
var memory_tile_ids = [];
var tiles_flipped = 0;

//shuffle method prototype
Array.prototype.memory_tile_shuffle = function () {
    var i = this.length, j, temp;
    while(--i > 0) {
        j = Math.floor(Math.random() * (i + 1));
        temp = this[j];
        this[j] = this[i];
        this[i] = temp;
}//shuffle prototype ending

function newBoard() {
    tiles_flipped = 0;
    var output = '';
    for(var i = 0; i < memory_array.length; i++) {
        output += '<div id="tile_'+i+'" onclick="memoryFlipTile(this,\''+memory_array[i]+'\')"></div>';
    }//For loop ending
  document.getElementById('memory_board').innerHTML = output;
}//function end

function memoryFlipTile(tile,val){
    if(tile.innerHTML == "" && memory_values.length < 2){ = '#FFF';
        tile.innerHTML = val;
        if(memory_values.length == 0){
        } else if(memory_values.length == 1){
            if(memory_values[0] == memory_values[1]){
                tiles_flipped += 2;
                // Clear both arrays
                memory_values = [];
                memory_tile_ids = [];
                // Check to see if the whole board is cleared
                if(tiles_flipped == memory_array.length){
                    alert("Board cleared... generating new board");
                    document.getElementById('memory_board').innerHTML = "";
            } else {
                function flip2Back(){
                    // Flip the 2 tiles back over
                    var tile_1 = document.getElementById(memory_tile_ids[0]);
                    var tile_2 = document.getElementById(memory_tile_ids[1]);
           = 'url( no-repeat';
                    tile_1.innerHTML = "";
           = 'url( no-repeat';
                    tile_2.innerHTML = "";
                    // Clear both arrays
                    memory_values = [];
                    memory_tile_ids = [];
                setTimeout(flip2Back, 700);


  <div id = "mainHeading">
    <h1>Memory Game</h1>
    <h2>Match any 2 squares</h2>
    <div id ="memory_board"></div>



                #mainHeading {
font-family: Oswald;
#mainHeading h1 {
font-size: 3.5em

div#memory_board {
    background: black;
    border: 6px solid rgba(100, 100, 100, .9);
    height: 540px;
    padding: 24px;
    margin: 50px auto 0 auto;
  border: 5px solid rgba(200, 200, 200, .5);
border-radius: 50px;
box-shadow: 10px 10px 10px #888888;
border-top-width: 10px;
border-top-color: rgba(100,100,100, .9);

div#memory_board > div {
    background: url( no-repeat;
    border: white 1px solid;
    width: 71px;
    height: 71px;
    float: left;
    margin: 10px;
    padding: 20px;
    font-size: 64px;
    cursor: pointer;
    text-align: center;