xxxxxxxxxx
23
let myArray = [2,5,7,3];
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
console.log(myArray)
}
function mousePressed(){
//myArray.pop(); //method to delete last element
//myArray.push('myString'); //method to add another element the array at the end
//myArray.shift(); //deleting the first element
//myArray.unshift('myString'); //method to add an element to the beginning
//myArray.splice(1,1); //removing things in the array at any point, index, [count] opt, [item] opt - delete the 2nd element from the array
//myArray.splice(1,1,"myString"); //replace 2nd element with myString
//myArray.splice(1,0,'myString'); //add myString added before the 2nd element
myArray.splice(1,1,'myString','anotherString'); //replaces 2nd element with two strings
}