From 3e6c2b58c29d9fa9effe9467f119499e977453eb Mon Sep 17 00:00:00 2001 From: gauthiier Date: Sun, 15 Jan 2023 11:32:42 +0100 Subject: [PATCH] 2.0 Array + Index --- 2.Ghost-Writing.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/2.Ghost-Writing.md b/2.Ghost-Writing.md index a530d1f..89343ae 100644 --- a/2.Ghost-Writing.md +++ b/2.Ghost-Writing.md @@ -4,6 +4,7 @@ autopilot creativity

+## Sketch: 2.0 Array + Index ```javascript // Array + Index! @@ -28,8 +29,21 @@ function keyTyped() { // Reference: https://p5js.org/reference/ ``` +### 🤔 What are indices? + ```javascript ["David", "Karin", "Sigrid", "Nanna", "Laura", "Maaikke"] <--- Array (var NAMES) | | | | | | 0 1 2 3 4 5 <--- indices (var INDEX) -``` \ No newline at end of file +``` + +### 📚 Exercice + +1. Modify sketch 2.0 so that: +* When key 'k' is pressed then "Hi Karin!" is printed on the console +* When key 's' is pressed then "Hi Sigrid!" is printed on the console +* When key 'n' is pressed then "Hi Nanna!" is printed on the console +* When key 'm' is pressed then "Hi Maaike!" is printed on the console + +2. Modify sketch 2.0 so that: +* Every time key 'x' is pressed then print the name of the following person in the array ("Hi David!", "Hi Karin!", "Hi Sigrid!", and so forth) \ No newline at end of file