title: Return index of array indices if sum is equal to target
body: <p>I am trying to prepare myself for coding interviews using <a href="https://leetcode.com" rel="nofollow noreferrer">leetcode</a>. In the first problem I have to return the index of the numbers whose sum is equal to the given target. My result satisfies 13 tests out of 19. The problem fails at </p>
  
  <pre><code>Input:
  [3,3]. target=6
  Output:
  undefined
  Expected:
  [0,1]
  </code></pre>
  
  <p>Can someone please give me a hint where am I failing?</p>
  
  <p>My solution:</p>
  
  <pre><code>/**
   * @param {number[]} nums
   * @param {number} target
   * @return {number[]}
   */
  var twoSum = function(nums, target) {
      for (var i=0; i&lt; nums.length; i++)
      {
          for (var j=1; j&lt; (nums.length-1); j++)
          {
              if ((nums[i]+nums[j]) == target)
                  {
                      var arr = [nums.indexOf(nums[i]), nums.indexOf(nums[j])];
                      arr.sort();
                      return arr;
                  }
          }
      }
  };
  </code></pre>