Javascript Array twoSum(target)

Description

Javascript Array twoSum(target)

Array.prototype.twoSum = function(target) {
  for (let i = 0; i < this.length; i++) {
    for (let j = i + 1; j < this.length; j++) {
      if (this[i] + this[j] === target) return true;
    }/*  w ww  .ja  v a2s  .  c om*/
  }
  return false;
}



PreviousNext

Related