Saturday, February 4, 2017

JS30 Challenge Day 15 - localStorage



Last but not the least, and the longest one of them all!
I have added some extra functionality to my solution in this one.

form elements have a reset method in them
this.reset();

JSON.stringify();
JSON.parse();

    localStorage.setItem('items',JSON.stringify(items));

For the clearAll function, 
I had to define items as let instead of const because I need to reset it to [] an empty array in the clearAll function.

UncheckAll was pretty straightforward.
Just remember to define the new buttons outside the form, because we have already used event delegation on the form.

An event delegation is like giving a task to a responsible parent.

If you give the task to its kids, they may not behave, so you delegate it.

No comments:

Post a Comment