4 Images - 4 Text Boxes

So I tried my hand at writing a constructor function that places 4 images (the images are stand ins for rodents since said rodents can’t be found in the imageGetImage library) on the page with the following caption above the images - You know a (Rodent.type)(Rodent.dangerous) a pest. But all the images are placed at all 4 locations, What am I doing wrong?
I thought that my code had unique X,Y locators for each image so how the heck did all 4 images get placed in each of the 4 locations?


var Rodents = function(x,y,type,dangerous)	{
	this.x = x;
	this.y = y;
	this.type = type;
	this.dangerous = dangerous;
};
var firstRodent = new Rodents(300,200,"rat","is");
var secondRodent = new Rodents(10,200,"beaver","is not");
var thirdRodent = new Rodents(10,30,"mouse","is");
var fourthRodent = new Rodents(300,30,"chipmunk","is not");
var drawRodents = function(Rodents){
	var Chipmunk = getImage("avatars/duskpin-seedling");
	var Mouse = getImage("avatars/aqualine-sapling");
	var Beaver = getImage("avatars/leaf-blue");
	var Rat = getImage("avatars/leaf-red");
	textSize(20);
	fill(10,200,10);
	var txt = ("You know a " + Rodents.type + " " + Rodents.dangerous +  " a pest");
	text(txt,Rodents.x,Rodents.y - 10);
	image(Chipmunk,Rodents.x,Rodents.y);
	image(Mouse,Rodents.x,Rodents.y);
	image(Beaver,Rodents.x,Rodents.y);
	image(Rat,Rodents.x,Rodents.y);
};
drawRodents(firstRodent);
drawRodents(secondRodent);
drawRodents(thirdRodent);
drawRodents(fourthRodent);

this is the final graphic result and although I can’t be sure, I think all 4 images are superimposed on one another

Because you’re drawing all 4 images :laughing: :

	image(Chipmunk,Rodents.x,Rodents.y);
	image(Mouse,Rodents.x,Rodents.y);
	image(Beaver,Rodents.x,Rodents.y);
	image(Rat,Rodents.x,Rodents.y);

OK so I rewrote the code with some new variables that I thought were better named to reflect what I was trying to do and the end result was to be 4 images as before with the appropriate captions - but - sigh - nothing prints out - so I wonder what it is this time?

var Rodents = function(x,y,type,isisnot,image)	{
	this.x = x;
	this.y = y;
	this.type = type;
	this.isisnot = isisnot;
	this.image = image;
};
var Mouse = new Rodents(10,30,""mouse","is",getImage("avatars/aqualine-sapling"));
var Chipmunk = new Rodents(300,30,"chipmunk","is not",getImage("avatars/aqualine-sapling"));
var Beaver = new Rodents(10,200,"beaver","is not",getImage("avatars/leaf-blue"));
var Rat = new Rodents(300,200,"rat","is",getImage("avatars/leaf-red"));
var drawRodents = function(Rodents)	(
	textSize(20);
	fill(10,200,10);
	var txt = ("You know a " + Rodents.type + " " + Rodents.isisnot + " a pest.");
	text(txt,Rodents.x,Rodents.y - 10);
	image(Rodents.image,Rodents.x,Rodents.y);
);
drawRodents(Mouse);
drawRodents(Chipmunk);
drawRodents(Beaver);
drawRodents(Rat);

Looks like you have a double-double quote for mouse. I added code formatting to your post (I’ve been doing it with most of your posts) so you can see the error there more clearly as the string coloring gets swapped where the two quote characters are.

Yikes! Right you are! So I eliminated the double quote - still the darn thing would not print - then I realized the drawRodents function had ( )'s instead of the required { }'s - once the correction was made the graphic printed out as wanted - so there’s hope for me yet