From 927517b46f8a2a796ca3114f29240ed9ae1b8866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Patrick=20Deba=C3=ABne?= Date: Tue, 18 Apr 2023 22:09:15 +0200 Subject: [PATCH] section 12: arrays --- session12/challenge1.js | 9 +++++++++ session12/challenge2.js | 5 +++++ session12/challenge3.js | 7 +++++++ session12/challenge4.js | 13 +++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 session12/challenge1.js create mode 100644 session12/challenge2.js create mode 100644 session12/challenge3.js create mode 100644 session12/challenge4.js diff --git a/session12/challenge1.js b/session12/challenge1.js new file mode 100644 index 0000000..e4e82fc --- /dev/null +++ b/session12/challenge1.js @@ -0,0 +1,9 @@ + +let monTableau2D = [ + ['Mark', 'Jeff', 'Bill'], + ['Zuckerberg', 'Bezos', 'Gates'] +] + +monTableau2D.splice(2, 0, ['30', '45', '65']); + +console.log(monTableau2D); \ No newline at end of file diff --git a/session12/challenge2.js b/session12/challenge2.js new file mode 100644 index 0000000..902eab5 --- /dev/null +++ b/session12/challenge2.js @@ -0,0 +1,5 @@ +let panier = ['fraise', 'banane', 'poire']; + +for (const fruit of panier) { + console.log(panier.indexOf(fruit)); +} \ No newline at end of file diff --git a/session12/challenge3.js b/session12/challenge3.js new file mode 100644 index 0000000..b74c9ea --- /dev/null +++ b/session12/challenge3.js @@ -0,0 +1,7 @@ +let listeDepays = ['France', 'Belgique', 'Japon', 'Maroc']; + +// for (const pays of listeDepays) { +// console.log(pays); +// } + +listeDepays.forEach(pays => console.log(pays)) \ No newline at end of file diff --git a/session12/challenge4.js b/session12/challenge4.js new file mode 100644 index 0000000..510dc1a --- /dev/null +++ b/session12/challenge4.js @@ -0,0 +1,13 @@ +let monTableauAssociatif = { + 'prenom' : 'Mark', + 'nom' : 'Zuckerberg', + 'poste' : 'PDG de Facebook' +}; + +function toString(tableau) { + for (const valeur in tableau) { + console.log(valeur + ' : ' + tableau[valeur]); + } +} + +toString(monTableauAssociatif); \ No newline at end of file