Is there a way to create a specific instance of SmileyFace, and pass the name of that as the argument to drawSmiley()

Viewed 16

var faceObj = {
    centerX: 100, 
    centerY: 100
};

var drawSmiley = function(faceObj) {
    fill(168, 124, 70);
    ellipse(faceObj.centerX, faceObj.centerY, 150, 150);
    fill(0, 0, 0);
    ellipse(faceObj.centerX-30, faceObj.centerY-30, 20, 20); 
    ellipse(faceObj.centerX+30, faceObj.centerY-30, 20, 20); 
    noFill(); 
    strokeWeight(3);
    arc(faceObj.centerX, faceObj.centerY+10, 64, 40, 0, 180);
};

var SmileyFace = function(x, y) {
    this.centerX = x;
    this.centerY = y;
};

//SmileyFace.speak('hello!');

var faceObj = new SmileyFace(this.centerX, this.centerY);
drawSmiley(SmileyFace);

var faceObj = new SmileyFace(100, 100);

How do I answer this statement while still maintaining this code? "You’re passing the name of the object (SmileyFace) as the argument when you call drawSmiley(). Instead, create a specific instance of SmileyFace, and pass the name of that as the argument to drawSmiley()."

0 Answers
Related