← Back to challenges

Determine If Two Numbers Add up to a Target Value

JavaScriptHardarraysvalidationnumbers

Instructions

Given two unique integer arrays a and b, and an integer target value v, create a function to determine whether there is a pair of numbers that add up to the target value v, where one number comes from one array a and the other comes from the second array b.

Return true if there is a pair that adds up to the target value and false otherwise.

Examples

sumOfTwo([1, 2], [4, 5, 6], 5) ➞ true

sumOfTwo([1, 2], [4, 5, 6], 8) ➞ true

sumOfTwo([1, 2], [4, 5, 6], 3) ➞ false

sumOfTwo([1, 2], [4, 5, 6], 9) ➞ false

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Back and Forth