CodingTrain / CodingTrain/Suggestion-Box

p5.js tutorial - advanced arrays (jagged 2d array of objects)

Ouverte
#397 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Help wanted Suggestion
Langage dominant
Aucune donnée de langage
Étoiles
570
Forks
85
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

A follow up to tutorial 9.12: 2D Arrays in JavaScript

Data doesn't always come in neat 4x7 element packages; sometimes it is irregular. I'm not entirely sure what the represented limits are in p5.js - I believe you can make an array of arrays, but how about when dimensions get jagged? Or an array of jagged arrays of objects?

Consider one example: gift boxes under a Christmas tree.
A box might be represented as an object with several properties -

- recipient
- an array of things inside

You might want to organize them several ways -
the simplest is an array of all boxes, but what if you wanted an array of Senders, and each element of this array contained an array of boxes sent by them.

Would this be possible to represent? How would one enumerate the various arrays, or get the lengths?

What would the syntax be for the length of a Sender list?

If boxes[sender][item] was the syntax for one item, how would one get the number of items from a sender? How would one get the number of senders?

Could this data be extended to include an item name and cost? These things periodically haunt my dreams...

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

Commencez par examiner le tutoriel 9.12, « 2D Arrays in JavaScript », ainsi que les exemples décrits dans cette issue. Définissez le périmètre d’un tutoriel avancé couvrant les tableaux irréguliers, les tableaux d’objets, l’indexation imbriquée et la récupération des longueurs des collections. La tâche est considérée comme terminée lorsque le tutoriel explique et démontre clairement la structure de données de boîte-cadeau proposée et ses questions.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
javascript
Domaine
documentation
Type d'issue
Documentation
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.