Combined Logging Demo Experiment Run Experiment

Combined Logging

Jaap Murre

Demonstrates how you can combine the inputs from several controls and log it as a string. It also shows how to check whether a certain word is contained within the subject’s answer.


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.

// Several input questions
input("What is your favorite fruit?","fruit");
input("What is your favorite drink?","drink");
input("What is your favorite animal","animal");

// They are combined into an array using the response object
var results = [ response["fruit"].toLowerCase(), 
                response["drink"].toLowerCase(), 
                response["animal"].toLowerCase() ];

// Use the console.log() function to inspect the array in the console
// Use F12 on Windows to make the console visible
console.log("Results: ",results);

// For logging purposes, it is best to convert the array into a string:
var s = results.join(","); // Join the elements with , (comma) between them

console.log("String: ",s); // Show the string in the console

log(s,"combined_inputs"); // Now log the string to your account

var cat_counter = 0; // Count the number of cat answers one subject gives


// indexOf('cat') returns the 0-based position of the word cat
if (response["animal"].indexOf("cat") === -1) {
    console.log("No cat");
}
else
{
    console.log("Cat!");
    cat_counter = cat_counter + 1;
    // cat_counter += 1;
    // cat_counter++;
}

You can download the files as follows: Click on the file (link) and then right-click and choose Save as... from the menu. Some media files (e.g., sound) will have a download button for this purpose.

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