mousePressed method firing early

I wrote the following code hoping to have an answer paragraph display when the ‘Check Answer’ button is clicked. But for some reason the answer is displaying immediately when the page loads - no clicks needed. What am I doing wrong?

function setup () {
var ans = generate();
var checkMe = createButton(‘Check Answer’);
checkMe.mousePressed(createP(ans));
}

Answers

Sign In or Register to comment.