How to use print() for dialogue. How to update the string?

#1
#2

Hey there, great question, and glad to hear that the syntax of JavaScript is becoming 2nd nature!

There isn’t a way to delete a print command that has already executed, but you can still print another string, which should be good enough.

Because you want to print the string only when the ball has been tapped, you can add the print command to the callback function for the event handler. It would look like this:

ball.on('click', () => {
    ball.transition().attr('cx',100).attr('cy',100).duration(2000);
    print('you chose the ball instead of the square!');
})

Hope this helps!
Ben