I have an array of words - my stimuli - and they are presented on the screen. Yet, each word has another "condition", that is they are either, say categoryA, categoryB, or categoryC. This is probably simple, but I couldn't find an answer and am stuck with it.
My final aim is to assign the categories randomly to the stimuli each time the script is run.
var stim = [ "AEROPLANE", "TRAIN", "CAR", "BIKE", "WALKING"];
Here I'd like AEROPLANE to have categA, TRAIN categB, and the rest categC.
I thought about something like this (or with integers instead of Letters):
var stim = [ ["AEROPLANE", A], ["TRAIN", B], ["CAR", C], ["BIKE", C], ["WALKING",C] ];
But this doesn't work. If I have categories, how would I access them to code responses?
This is the script that presents the stimuli (on each keypress a new one):
$(function(){
$(document).keypress(function(e){
if ($(e.target).is('input, textarea')) {
return;
};
if (e.which === 97 || e.which === 108) {
new_word = w_stim[Math.floor(Math.random() * stim.length)];;
$("#abc").text(new_word);
};
});
});