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.

            
              <!DOCTYPE html>

<html>

<head>

    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1">

    <meta name="description" content="Unlimited grammar practice exercises of 
    each & every topic to get a good commmand of English language">

    <link rel="stylesheet" type="text/css" href="jumbled.css">

    <script type="text/javascript" src="jquery.js"> </script>

    <script type="text/javascript" src="jumbled.js"> </script>

    <title> Jumbled Letters </title>

</head>

<body>

    <div id="score"> Score </div>

    <div id="answerDiv"> </div>

    <div id="questionDiv"> </div>

    <div id="summary">

        <h3> Summary Screen </h3>

        <p> Your score: x out of y </p>

        <a class="rst" href="#"> Restart Quiz </a>

    </div>

    <button id="btn"> Submit </button>

</body>

</html>

            
          
!
            
              
    #questionDiv {
        width: 500px;
        height: 320px;
        background: #f0e4e4;
        font-size: 25px;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(3, 1fr);
        grid-gap: 3px;
        justify-content: center;
        align-content: center;
        border: 2px solid #065f06;
        position: absolute;
        top: 160px;
        left: 430px;

    }

    .letter {
        text-transform: capitalize;
        text-align: center;
        padding: 30px;
        cursor: pointer;
        font-size: 30px;

    }

    .letter:hover {
        background: antiquewhite !important;
        color: darkred;
        font-weight: bold;

    }


    #query {
        text-transform: uppercase;
        color: white;
        font-weight: bold;
        font-size: 30px;
        background: black !important;
        text-align: center;
        padding: 40px;
        letter-spacing: 3px;

    }


    #questionDiv div:nth-child(odd) {
        background: #b3ebba;

    }


    #questionDiv div:nth-child(even) {
        background: #68ed62;

    }


    #questionDiv div:nth-child(1) {

        order: 9;

    }

    #questionDiv div:nth-child(2) {

        order: 8;

    }

    #questionDiv div:nth-child(3) {

        order: 7;

    }

    #questionDiv div:nth-child(4) {

        order: 6;

    }

    #questionDiv div:nth-child(1) {

        order: 5;

    }

    #questionDiv div:nth-child(1) {

        order: 5;

    }

    #answerDiv {
        width: 100%;
        width: 795px;
        height: 100%;
        height: 85px;
        background: #f5cc7f;
        position: relative;
        left: 250px;
        top: 5px;
        border: 1px solid black;
        display: flex;

    }

    .box {
        width: 100px;
        height: 10px;
        border: 2px solid #a26c07;
        font-size: 40px;
        padding: 36px 5px;
        line-height: 10px;
        color: white;
        text-align: center;
        color: wheat;
        background: #4a3510;
        display: none;

    }


    #btn {
        position: relative;
        top: 350px;
        left: 600px;
        padding: 10px;
        font-size: 25px;
        font-weight: bold;
        cursor: pointer;
        border: 2px solid black;

    }

    #btn:hover {
        background: black;
        color: antiquewhite;

    }

    #score {
        background: antiquewhite;
        font-size: 25px;
        width: 70px;
        height: 50px;
        text-align: center;
        line-height: 45px;
        margin: 0px auto;
        border: 2px solid black;
        border-radius: 10px;

    }

    #summary {
        width: 500px;
        height: 300px;
        background: #403a3a;
        color: white;
        font-weight: bold;
        font-size: 30px;
        text-align: center;
        letter-spacing: 2px;
        cursor: pointer;
        position: absolute;
        top: 120px;
        left: 400px;
        display: none;

    }

    #summary a {
        text-decoration: none;
        color: antiquewhite;
        border: 2px solid wheat;
        border-radius: 6px;
        padding: 10px 20px;
        position: relative;
        top: 30px;
        background: #4a2f06;

    }

    #summary a:hover {
        background: white;
        color: black;

    }

    #summary h3 {
        color: wheat;

    }




            
          
!
            
              $(document).ready(function () {

    var jumbled = [

        {
            question: "LTPOHSIA",
            letters: ['A', 'I', 'S', 'H', 'O', 'P', 'T', 'L'],
            answer: "HOSPITAL"


        },

        {
            question: "HMANSODE",
            letters: ['M', 'E', 'H', 'N', 'D', 'O', 'A', 'S'],
            answer: "HANDSOME"


        },

        {
            question: "ADITNOID",
            letters: ['A', 'I', 'D', 'O', 'N', 'T', 'I', 'D'],
            answer: "ADDITION"


        },

        {
            question: "BSNISUES",
            letters: ['S', 'E', 'U', 'S', 'I', 'N', 'S', 'B'],
            answer: "BUSINESS"


        },

        {
            question: "XEREESIC",
            letters: ['X', 'E', 'R', 'E', 'S', 'I', 'C', 'E'],
            answer: "EXERCISE"

        },


    ];


    // Showing letters in divs

    $(document).on('click', '#btn', showQuestions);

    var x = "";

    var i = 0;

    function showQuestions() {

        document.getElementById('questionDiv').innerHTML = x;

        for (j = 0; j < jumbled[i].letters.length; j++) {

            if (i < jumbled.length) {

                $('#questionDiv').append("<div id=" + jumbled[i].letters[j] + " class='letter'>" + jumbled[i].letters[j] + "</div>");


            }

        }


        // Showing Questions

        if (i < jumbled.length) {

            $('#questionDiv').append('<div id="query">' + jumbled[i].question + '</div>');

            i++;

        }

        $('.box').hide();

        count = 0;

    }

    showQuestions();

    // Creating multiple divs in answerDiv

    function createDivs() {

        for (k = 0; k <= 8; k++) {

            var div = document.createElement('div');

            div.className = "box";

            document.getElementById('answerDiv').appendChild(div);


        }

    }

    createDivs();


    // Click to move letter to box div


    guessArray = [];

    count = 0;

    $(document).on('click', '.letter', hello);

    function hello()


    {

        $('.box:eq(' + count + ')').html($(this).text());

        $(this).html('');

        $(this).prop('disabled', true);

        $('.box:eq(' + count + ')').show();

        guess = $('.box:eq(' + count + ')').html();

        guessArray.push(guess);

        newArray = guessArray.join('');

        count++;

    }

    // Checking Answers

    n = 0;

    score = 0;

    $('body').on('click', '#btn', world);

    function world() {


        if (n <= jumbled.length) {

            correct = jumbled[n].answer;

            n++;

        }

        if (newArray === correct) {

            score++;

        }


        if (score <= jumbled.length) {

            z = score;

            document.getElementById('score').innerHTML = z;

        }

        if (n >= jumbled.length) {

            $('#summary').fadeIn();

            $('#questionDiv').fadeOut();

            $('#answerDiv').fadeOut();

            $('#score').fadeOut();

            $('#btn').fadeOut();

            $('#summary p').text("Your Score: " + score + " out of " + jumbled.length + " correct ");

        }


        guessArray = [];

        console.log(correct, newArray);

    }


    // Restarting Quiz

    $(document).on('click', '#summary a', restart);

    function restart()

    {

        i = 0;
        k = 0;
        n = 0;

        score = 0;

        $('#summary').fadeOut();

        $('#questionDiv').fadeIn();

        $('#answerDiv').empty();

        $('#answerDiv').fadeIn();

        $('#score').fadeIn();

        $('#btn').fadeIn();

        showQuestions();

        hello();

        world();

        createDivs();

    }

});

            
          
!
999px
🕑 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.

Console