We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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
checkMe.mousePressed(createP(ans));
you're actually invoking function createP(). #-o=>
: :>https://Developer.Mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
checkMe.mousePressed(() => createP(ans));
:-bd