Skip to content

Instantly share code, notes, and snippets.

@ddallala
Created February 12, 2018 22:01
Show Gist options
  • Select an option

  • Save ddallala/45dd57d2e044471b6078715ce1501741 to your computer and use it in GitHub Desktop.

Select an option

Save ddallala/45dd57d2e044471b6078715ce1501741 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/jizipug
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
// remove duplicates from array
function removeDuplicates(a){
var hash = {};
var clean_array = [];
for(var i=0;i<a.length;i++){
if(!hash[a[i]]) {
clean_array.push(a[i]);
hash[a[i]] = true;
}
}
return clean_array;
}
console.log(removeDuplicates([1,2,5,4,3,2,3,4,5,6]))
</script>
<script id="jsbin-source-javascript" type="text/javascript">// remove duplicates from array
function removeDuplicates(a){
var hash = {};
var clean_array = [];
for(var i=0;i<a.length;i++){
if(!hash[a[i]]) {
clean_array.push(a[i]);
hash[a[i]] = true;
}
}
return clean_array;
}
console.log(removeDuplicates([1,2,5,4,3,2,3,4,5,6]))</script></body>
</html>
// remove duplicates from array
function removeDuplicates(a){
var hash = {};
var clean_array = [];
for(var i=0;i<a.length;i++){
if(!hash[a[i]]) {
clean_array.push(a[i]);
hash[a[i]] = true;
}
}
return clean_array;
}
console.log(removeDuplicates([1,2,5,4,3,2,3,4,5,6]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment