xxxxxxxxxx
22
//substring reference https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring
let sentence = "A rose is a rose is a rose";
let num = 0;
function setup() {
createCanvas(400, 400);
textSize(18);
fill(255);
}
function draw() {
background(185, 20, 222);
text(sentence.substring(0, num), 100, height / 2);
if (num < sentence.length){
num++;
}
}
function mousePressed() {
num = 0;
}