scrimba
Note at 0:15
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Note at 0:15
by
AboutCommentsNotes
Note at 0:15
by
Expand for more info
main.js
run
preview
console
function sumOfTwo(nums1, nums2, value){
//write code here
const map = {}
for(let num of nums1){
const difference = value - num;
map[difference] = difference
}
for(let num of nums2){
if(map.hasOwnProperty(num)){
return true
}
}
return false
}



/**
* Test Suite
*/
describe('sumOfTwo()', () => {
it('returns true if a value can be found that by adding one number from each list', () => {
// arrange
const nums1 = [1, 2, 3];
const nums2 = [10, 20, 30, 40];
const value = 42;

// act
const result = sumOfTwo(nums1, nums2, value);

// log
console.log("result: ", result);

// assert
expect(result).toBe(true);
});
});
Console
"result: "
,
true
,
/index.html
LIVE