v1
6/18/2020 by Seasle 6/18/202000
Setup HTML - click to add setup HTML
disable setup JavaScript
Setup JavaScript
const removeNonUnique1 = array => {
  const dict = array.reduce((acc,it) => {
    if(acc[it]){
      acc[it] = {...acc[it], count: acc[it].count + 1}
      return acc
    }
    acc[it] = {value: it, count: 1}
    return acc
  }, {})

  return Object.keys(dict).filter((it) => dict[it].count < 2)
}

const removeNonUnique2 = array => {
    const cache = new Set();
    const store = new Set();

    for (const entry of array) {
        if (cache.has(entry)) {
            store.delete(entry);
        } else {
            store.add(entry);
          cache.add(entry);
        }
    }

    return [...store];
};

const array = new Array(1e3).fill(null).map(() => Math.floor(Math.random() * 1e3));
delete caserun single casemove downdrag and drop case


ready



removeNonUnique1(array);
delete caserun single casemove updrag and drop case


ready



removeNonUnique2(array);
Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN