In dieser Aufgabenserie lernst du mit Arrays umzugehen.
Weitere Informationen dazu findest du unter: array
let numbers = [1, 3, 5, 7, 9];
function setup() {
// dieser Befehl gibt die Zahl 3 aus
console.log(numbers[1]);
// dieser Befehl gibt das 5. Element aus
console.log(numbers[4]);
}
let words = ['Ein', 'Hase', 'frisst', 'gerne', 'Gras'];
function setup() {
console.log(words[0]);
console.log(words[1]);
console.log(words[2]);
console.log(words[3]);
console.log(words[4]);
words[0] = 'Eine';
words[1] = 'Kuh';
console.log(words[0]);
console.log(words[1]);
console.log(words[2]);
console.log(words[3]);
console.log(words[4]);
words.splice(4, 1);
console.log(words[0]);
console.log(words[1]);
console.log(words[2]);
console.log(words[3]);
words.push('Heu');
console.log(words[0]);
console.log(words[1]);
console.log(words[2]);
console.log(words[3]);
console.log(words[4]);
}
let xCoords = [50, 100, 150, 200, 300];
let yCoords = [100, 200, 50, 150, 300]
function setup() {
createCanvas(400, 400);
}
function draw() {
background(100);
ellipse(xCoords[0], yCoords[0], 50, 50);
ellipse(xCoords[1], yCoords[1], 50, 50);
ellipse(xCoords[2], yCoords[2], 50, 50);
ellipse(xCoords[3], yCoords[3], 50, 50);
ellipse(xCoords[4], yCoords[4], 50, 50);
}