xxxxxxxxxx
46
// declare some arrays
// declare an array of greetings
let greetings = [
"hello",
"greetings",
"namaste",
"你好",
"bonjour",
"howdy",
"hola",
"hej",
"ahoj",
];
// declare an array of numbers
let numbers = [134, 2036, 343, 12, -3.12];
// declare an empty array of bubbles
let bubbles = [];
// declare an array containing mixed values
let mixedArray = [0, "string", 2, 11, "really?"];
function setup() {
createCanvas(400, 400);
textSize(15);
}
function draw() {
background(220);
// push() to add in new items to array
greetings.push("hhhhhhtest")
//splice() to delete slice of array
//this will delete bonjour and howdy
//greetings.splice(4,2)
for (let i = 0; i < greetings.length; i++) {
text(greetings[i], 20, 30 + i * 20);
}
noLoop();
}