I don’t understand why this code works. Here, addOrUpdateTask is declared above updateTaskContainer, but it uses updateTaskContainer. This can only work with function declarations. Or am I wrong?
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
<button type="button" class="btn">Edit</button>
<button type="button" class="btn">Delete</button>
///
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
and that depends on when updateTaskContainer is executed, not in order of declaration, as long as addOrUpdateTask exists once updateTaskContainer executes, then everything works as intended
Do you mean that updateTaskContainer()
reset() are considered to be called at the same time as addOrUpdateTask, since they are called inside addOrUpdateTask?
it’s not exactly at the same time, but when addOrUpdateTask is called, those will be called by consequence as there are function calls to those functions inside addOrUpdateTask
and then, since the functions are created when the app loads, but are called only when the button is clicked, the functions all exist at that point, so there is no issue with the order of declaration
you can’t, but the order in which you see the lines, and the order in which the lines are executed is often not the same, and to the code it’s order of execution that matters