I'm currently developing a daily task organizer for work. The data is being pulled from local storage successfully. I am facing an issue while iterating through an array of objects and trying to retrieve data based on matching IDs. These objects have two properties - hour and description, with the hour acting as the unique identifier. However, when retrieving the data from localStorage, the targeted object's data is duplicated in every textarea.
Is there a way to display the data only in the corresponding textarea with the matching ID?
The problematic section of my code seems to be:
for (var i = 0; i < timeBlockArr.length; i++) {
var timeBlockId = $(".time-block").attr("id");
if(timeBlockArr[i].hour === timeBlockId) {
$(".time-block .description").val(timeBlockArr[i].description);
}
}
You can view the working project on jsFiddle here: https://jsfiddle.net/j9hepL2b/