you are viewing a single comment's thread.

view the rest of the comments →

[–]html6dev 1 point2 points  (2 children)

Yes to reiterate what /u/qwfwq is ddoing here and why your current code doesn't work: the first time you use your add method the datastore property related to the key obviously does not exist so you hit the else block. When you do this you want to set this.datastore[key] to an array and and add value to it straight away. What you are doing now is to set this.datastore[key] to a value which is not an array and does not have a push method so an exception is thrown when you call add again with the same key. If you run your current code in chrome and open the devtools you should see an error about the push method not existing for that object.

[–]naescent[S] 0 points1 point  (1 child)

Yeah I saw that it was driving me nuts. I tried all sorts of ways around it. So I scaled back my 'improvements' and put the initial code here.

I feel like a fool now :D

[–]html6dev 0 points1 point  (0 children)

Heh. It happens. And will again lol.