Closed maiquynhtruong closed 7 years ago
Why everything failed :/
This method is not persistent. Once you reload the page, it goes back to the original array. Therefore, I'm reverting this PR and closing it.
Looks like data in localStorage isn't saved when your reload the page? Or do you have any suggestions how to persist saved data when you reload page?
Using a localStorage library will be better.
I changed the usernames array to be stored with localStorage. This is for #6.
I have not make any changes to UI. I just wanted my code to be reviewed before it is merged. I was thinking about using some of the localStorage library but I have some problem with numeric keys and string values. I planned to do something like
for (var i = 0; i < USERNAMES.length; i++) { localStorage.setItem('user', {i: USERNAMES[i]}) }
to store the usernames in localStorage the same way you use an array. But that adds some complexity when you constantly add and remove items out of the array, i.e you constantly have to increment/decrement. So I resorted to using JSON.stringify() and JSON.parse(). Google search something like "localStorage array" to see more details.I'm not sure about your UI suggestions so let's discuss that. I'll make changes and we can merge later.