Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9217991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:45:33+00:00 2026-06-18T02:45:33+00:00

I have started learning javascript a couple of days ago and done the codeacadmey

  • 0

I have started learning javascript a couple of days ago and done the codeacadmey stuff and thought i will try make a simple game.

so i came up with the memory game where you have to find pairs of images.

it is all working and i got a score system in place but a few people have said the delay that happens once the cards have been chosen to allowing another chocie is hindering them and i cant figure out how to improve that performance.

here is a bit of code i think is causing the delay, is there any better way to produce the same result, sorry about before i am new to all this.

function check() {

    clearInterval(tid);

        if(people[secondchocie] === people[firstchocie]) {
            cntr++;

            (cntr === numOfMatches) {

                stop();

                score = checkScore(amountGoes); 


                $('#gameFinished').append('<p>Well done, you managed to complete the game your score is <span>' + score + '</span></p>');

                }
                turns = 0;
                return;


                } else {
                document.images[firstchocie + numOfImages].src = backcard;
                document.images[secondchocie + numOfImages].src = backcard;
                turns = 0;
                return;

                }

        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:45:35+00:00Added an answer on June 18, 2026 at 2:45 am

    I can’t create comments, so I’ll put this in an answer.

    Although I agree with lukas.pukenis …

    Changing images can take some time if they aren’t preloaded. To test this: Try to get them into the browser cache by adding them somewhere else in the page (i.e. with an IMG tag) before starting the game.

    Then you’ll be sure they are in the cache.

    edit:

    I recently used this:

    var cache = [];
    function preLoadImages(arrImg)
        {
        var args_len = arrImg.length;
        for (var i = args_len; i--;)
            {
            var cacheImage = document.createElement('img');
            cacheImage.src = arrImg[i];
            cache.push(cacheImage);
            }
        }
    preLoadImages(['images/img1.png','images/img2.png','images/img3.png',]);
    

    you can add all images needed to the javascript array.

    If your a quick study 🙂 you can do the following:
    If your page is generated by php you could let php read the entire images directory and write the filenames in the page as javascript code.
    Or you could create an ajax request wich returns all paths to the images and sends them to the preload function as a callback.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have started learning Javascript as part of developing very simple Firefox addons. The
Im just learning javascript the last days (started PHP some months ago). So, my
I have just started learning Jquery and am new to writing javascript (I am
I have started learning Java and I have 1 issue: I write a simple
I have just started learning Javascript. I want Hello World! to be written to
I have just started learning Javascript and I am absolutely overwhelmed with the number
I have some php and javascript experience and just started learning curl. Been messing
I have started learning the javascript module pattern and I have the following code:
Well, one more question. Since I started learning javascript short time ago, I am
I've just started learning javascript and have created a drag and drop using jquery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.