JSFiddle - React, Tailwind, and code Playground

by Steven Senkus

JavaScript

var twoSum = function(nums, target) {
    let indices = null;
        for (let i = 0; i < nums.length - 1; i++) {
            for (let j = i + 1; j < nums.length - 1; j++) {
                if (nums[i] + nums[j] === target) {
                	indices = [i,j];
                }
            }
        }
    return indices;
};

twoSum([1, 2, 4, 3, 5, 6], 3)