xsnippet logotype

xsnippet

#363102, Untitled [ Text only ]

by Guest
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
var checkDuplicates = function(array) {
  if (!array) {
    return false;  
  }
  
  var buffer = [];
  for (var i = 0; i < array.length; i++) {
    var item = array[i];
    if (buffer.indexOf(item) >= 0) {
      return true;
    } else {
      buffer.push(item);
    }
  }
  return false;
}

console.log(checkDuplicates([1,0,2, 3,17, 1]));