()
| 9 | * Add event listener to the lid-toggle button. |
| 10 | */ |
| 11 | const lidToggle = function () { |
| 12 | |
| 13 | // Find the current backpack object in backpackObjectArray |
| 14 | let backpackObject = backpackObjectArray.find( ({ id }) => id === this.parentElement.id ); |
| 15 | |
| 16 | // Toggle lidOpen status |
| 17 | backpackObject.lidOpen == true |
| 18 | ? backpackObject.lidOpen = false |
| 19 | : backpackObject.lidOpen = true; |
| 20 | |
| 21 | // Toggle button text |
| 22 | this.innerText == "Open lid" |
| 23 | ? this.innerText = "Close lid" |
| 24 | : this.innerText = "Open lid"; |
| 25 | |
| 26 | // Set visible property status text |
| 27 | let status = this.parentElement.querySelector(".backpack__lid span"); |
| 28 | status.innerText == "closed" |
| 29 | ? (status.innerText = "open") |
| 30 | : (status.innerText = "closed"); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * - Loop through backpackObjectArray |
nothing calls this directly
no outgoing calls
no test coverage detected