xxxxxxxxxx
40
let students = [
"Callie",
"Dean",
"Duban",
"Ege",
"Fiona",
"Jessie",
"Michelle",
"Omi",
"Shawn",
"Sophia",
"Surya"
];
let name;
function setup() {
createCanvas(400, 400);
name = random(students);
}
function draw() {
background(220);
textSize(20);
textAlign(CENTER);
text(`Element of the array, "students": \n\n ${name}`, width / 2, height / 4);
text(
`First element of the string, "${name}": \n\n ${name[0]}`,
width / 2,
(height * 2) / 3
);
}
function mousePressed() {
name = random(students);
// console.log(name, name.length)
}