Guide 04 / 4
Resources and review
Learn to consult documentation, solve an error and check what you have learned.
Find reliable information and explain what you have built.
01 · Consulting the references
The resources are linked at the bottom of the guide.
MDN · JavaScript Guide
Read the chapters on variables, functions and flow control. Redo the small examples with a recipe duration rather than an abstract number.
Example
Mission : écrire estRapide(20) puis estRapide(45).
MDN · querySelectorAll and events
Check the result type of querySelectorAll and the addEventListener examples. Find these uses again in app.js.
Example
Mission : compter les cartes sélectionnées avec cartes.length.
MDN · localStorage
Explore the difference between setItem, getItem and removeItem. Check which origin the storage belongs to.
Example
Mission : expliquer pourquoi changer de port peut changer les données accessibles.
02 · Troubleshooting and preparing for PHP
Read the console's first error first.
Cannot read properties of null
A selector does not find the expected element, or the script runs before it is created. Check the HTML ids, the selector spelling and defer.
Example
document.querySelector("#recherche") doit renvoyer un élément, pas null.
The filter or the counter seems wrong
Check data-titre, data-duree and Number. Check that visibles goes back to 0 on each call. If a card marked hidden stays visible, check the [hidden] CSS rule.
Example
Données de référence : soupe 20, salade 10, tarte 45.