scrimba
Note at 0:27
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:27
AboutCommentsNotes
Note at 0:27
Expand for more info
main.js
run
preview
console
function sumOfTwo(nums1, nums2, value) {
let isAMatch = false;
let matchInfo = '';
for (let i = 0; i < nums1.length; i++) {
//isAMatch = false;
for (let j = 0; j < nums2.length; j++) {
if (nums1[i] + nums2[j] === value) {
isAMatch = true;
// matchInfo += `Value: ${value} found using a combination of array1 index ${i} and array2 index ${j}. `
}
}
}
// console.log(matchInfo);
return isAMatch;
}



/**
* 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 nums1 = [1, 2, 3, 21];
// const nums2 = [10, 20, 30, 40, 21];
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