Created
February 12, 2018 22:01
-
-
Save ddallala/45dd57d2e044471b6078715ce1501741 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/jizipug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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