I am new to Javascript so I apologize if I am using the wrong terms. I have a code where I need to show some HTML images, stored as variables containing multiple items in specific positions (defined by the class) such as:
var fruit = ["<img class='item1' src='" + Banana + "'>" +
"<img class='item2' src='" + Apple + "'>" +
"<img class='item3' src='" + Grapes + "'>" +
"<img class='item4' src='" + Banana + "'>" +
"<img class='item5' src='" + Grapes + "'>" +
"<img class='item6' src='" + Pear + "'>"],
Later, I need to use all of these items in a bigger picture called stimulus, e.g.:
stimulus: "<div class='container'> <img class='background' src='" + Background + "'>" + fruit + "</div>",
But then I need to only show 3 random fruits among the 6 listed in fruit. For instance, I would need to get something like:
stimulus: "<div class='container'> <img class='background' src='" + Background + "'>" + half_fruit + "</div>",
Where:
var half_fruit = ["<img class='item1' src='" + Banana + "'>" + "<img class='item3' src='" + Grapes + "'>" + "<img class='item6' src='" + Pear + "'>"],
Is there any way I can do this, even if my images are not technically items of an array? I have specific fruit combinations (not just the one in the example, roughly 30 in total) and I need to remove 3 items of the ones in that specific combination while also leaving the others in the same position as they were before. This is why I am not storing images as strings in an array. Those variables are defined as var Banana = gorilla.stimuliURL('Banana.png'); etc. (Gorilla is a platform for creating experiments; the stimuliURL function calls image addresses from an online repository). Thank you for your time!