Menu
Coddy logo textTech

23. Two Sum

Lesson 24 of 31 in Coddy's 30 Days of Logic Building in Javascript course.

challenge icon

Challenge

Easy

Given an array of numbers and a target sum, find two numbers in the array that add up to the target and return their indexes!

  • Input: <strong>arr = [2, 7, 11, 15], target = 9</strong>
  • Expected Output: <strong>[0, 1]</strong> (2 + 7 = 9)

Try it yourself

function twoSum(arr, target) {
    // write your code below 
    
}

All lessons in 30 Days of Logic Building in Javascript