diff --git a/docs/Formular.md b/docs/Formular.md index 00983b1..bd80621 100644 --- a/docs/Formular.md +++ b/docs/Formular.md @@ -31,4 +31,41 @@ This part of the BMI calculator is responsible for **user input**. Users can ent 3. Click "BMI berechnen" 4. Result is displayed and saved 5. On reload: Data is still there -6. "Clear/Reset" deletes all data \ No newline at end of file +6. "Clear/Reset" deletes all data + + +## 💾 LocalStorage + +**Speicherort:** `localStorage['bmiData']` + +Daten werden nach der Berechnung als JSON-String gespeichert: + +```json +{ + "age": "25", + "date": "2025-02-23", + "weight": "75", + "height": "180", + "bmi": 23.1, + "category": "Normalgewicht", + "timestamp": "2025-02-23T14:30:45.123Z" +} +``` + +### Daten extrahieren +```javascript +// Einfaches Auslesen +const data = JSON.parse(localStorage.getItem('bmiData')); +console.log(data.bmi, data.category); + +// Mit Null-Check +if (localStorage.getItem('bmiData')) { + const data = JSON.parse(localStorage.getItem('bmiData')); + console.log('Gespeicherte Daten:', data); +} +``` + +### Daten löschen +```javascript +localStorage.removeItem('bmiData'); +``` \ No newline at end of file