fork download
  1. //get a column of an array
  2. Array.prototype.getColumn = function(name) {
  3. return this.map(function(el) {
  4. // gets corresponding 'column'
  5. if (el.hasOwnProperty(name)) return el[name];
  6. // removes undefined values
  7. }).filter(function(el) { return typeof el != 'undefined'; });
  8. };
  9. //dataArray = [10000000,12000000,12000000,13000000];
  10. //remove duplicates in an array
  11. Array.prototype.contains = function(v) {
  12. for(var i = 0; i < this.length; i++) {
  13. if(this[i] === v) return true;
  14. }
  15. return false;
  16. };
  17. Array.prototype.unique = function() {
  18. var arr = [];
  19. for(var i = 0; i < this.length; i++) {
  20. if(!arr.contains(this[i])) {
  21. arr.push(this[i]);
  22. }
  23. }
  24. return arr;
  25. };
Success #stdin #stdout 0.45s 321856KB
stdin
Standard input is empty
stdout
Standard output is empty