Skip to content

Instantly share code, notes, and snippets.

@ipekt
Created March 29, 2021 20:45
Show Gist options
  • Select an option

  • Save ipekt/bf32b30db6f8ccef3d45a9bfedbd3a1b to your computer and use it in GitHub Desktop.

Select an option

Save ipekt/bf32b30db6f8ccef3d45a9bfedbd3a1b to your computer and use it in GitHub Desktop.
Frequency Counter 2
function areThereDuplicates(...values) {
let counter = {};
for(let i=0; i<values.length; i++) {
if (counter[values[i]] === undefined) {
counter[values[i]] += 1;
} else {
return true;
}
}
return false;
}
areThereDuplicates(1,2,3,2); // true
areThereDuplicates(1,2,3); // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment