Stroop Task Demo Demo Experiment Run Experiment

Stroop Task Demo

Jaap Murre

Demo of the classic Stroop Task adjusted for the online use.


In the real Stroop task, the subject reads words or colors from a printed list. Here, we adopt to the online situation with the added advantage that we can automatically record reaction times. Note that this is only the ‘say color’ condition. It may be contrasted with ‘say word’ condition, which is expected to have much faster reaction times. This conditions only requires minimal changes to the script: different instructions and different scoring logic. We leave this as an exercise for the user.

If you are a registered user and signed in, you can here copy this script and its stimuli to your own account, where you can edit it and change it in any way you want.

It is absolutely free to register (no credit card info asked!). You can then instantly copy this experiment with one click and edit it, change its accompanying texts, its landing page, stimuli, etc. Invite your colleagues, friends, or students to check out your experiment. There is no limit on how many people can do your experiment, even with a free account.

The catch? There is no catch! Just keep in mind that with a free account, you cannot collect data. For teaching that is usually not a problem. For research, prepaid data collection (unlimited subjects) starts as low as €10.00 for a 10-day period.

var i, event, total_correct = 0, total_RT = 0;

// The following is an array with objects
// E.g., see https://www.w3schools.com/js/js_arrays.asp for how to use these
var trials = [
    {word: 'RED', color: 'green', key: 'g'},
    {word: 'BLUE', color: 'green', key: 'g'},
    {word: 'GREEN', color: 'red', key: 'r'},
    {word: 'RED', color: 'blue', key: 'b'},
    {word: 'GREEN', color: 'red', key: 'r'},
    {word: 'BLUE', color: 'green', key: 'g'},

    {word: 'BLUE', color: 'red', key: 'r'},
    {word: 'RED', color: 'blue', key: 'b'},
    {word: 'GREEN', color: 'blue', key: 'b'},
    {word: 'GREEN', color: 'red', key: 'r'},
    {word: 'BLUE', color: 'green', key: 'g'},
    {word: 'RED', color: 'blue', key: 'b'}
];

shuffle(trials); // Randomize trial order


// Here you might also have a condition with just XXXX instead of the word. This gives faster trials.


instruction("Press the first letter of the color in which the word is printed, ignoring the word itself: r, g, or b.");

text("The experiment will start shortly. Get ready!");
await(2000);

for (i = 0; i < trials.length; i++) {
    text("+").style("color","black");
    await(500);
    clear();
    await(Math.random());
    // Access your trial objects like this:
    text(trials[i].word).style("color",trials[i].color);
    event = await("keypress");
    total_RT = total_RT + event.RT;
    if (event.key === trials[i].key) {
        total_correct = total_correct + 1;
    }
    clear();
    await(1000);
}

text("Finished!").style("color","black");
await(1000);

// Give some feedback
instruction("You had " + total_correct + " correct, out of " + trials.length
            + ", with an average RT of " 
            + (total_RT/trials.length).toFixed(1) + " ms.","OK","Result");
            
text("Thank you for participating!");
await(2000); 
This experiment has no files of this type
This experiment has no files of this type
This experiment has no files of this type
This experiment has no YouTube links
This experiment has no files of this type