chingu-voyage4 / Bears-Team-15

Flashcards application

Home Page:https://cards-bears-15.herokuapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

User can make duplicate cards

svmi3195 opened this issue · comments

I can add duplicates of existing cards (with same q and a)

I wouldn't put tests for this issue on each input (q/a) change, but it would be great to have somewhere at this page a button "check for duplicates"

Or maybe "remove duplicates" to auto remove them instantly?

Also, if we really don't want duplicates we could use Sets to keep collections.

I've never heard of Sets, but took a look at this stuff at MDN:

var mySet = new Set();

mySet.add(1); // Set [ 1 ]
mySet.add(5); // Set [ 1, 5 ]
mySet.add(5); // Set [ 1, 5 ]
mySet.add('some text'); // Set [ 1, 5, 'some text' ]
var o = {a: 1, b: 2};
mySet.add(o);

mySet.add({a: 1, b: 2}); // o is referencing a different object so this is okay

so you really can add duplicate object to Set anyway :(

and yes, it should be "remove duplicates" button

Ah right, it doesn't go deep to compare object's properties. Will have to iterate through the collections then.