draw = function() {

background(165, 219, 162);
fill(255, 254, 222);
rect(20, 100, 364, 200);

fill(0, 0, 0);
textSize(20);
text("What programming language is this?", 39, 200);
if (mouseIsPressed){
text("javascript",200,200);
} else{
text("What programming language is this?",200,200);
}
};
I want to have "JavaScript" displayed only when I press the mousepad. how do I do that

1 answer

To only display "JavaScript" when the mousepad is pressed, you need to modify the code inside the `draw` function. Here's an updated code:

```javascript
draw = function() {
background(165, 219, 162);
fill(255, 254, 222);
rect(20, 100, 364, 200);

fill(0, 0, 0);
textSize(20);
text("What programming language is this?", 39, 200);

if (mouseIsPressed) {
fill(0, 0, 0);
textSize(20);
text("JavaScript", 200, 200);
}
};
```

With this code, the text "JavaScript" will be displayed at the position (200, 200) only when the mousepad is pressed.