Skip to content

Instantly share code, notes, and snippets.

@mbcarruthers
Created June 8, 2017 00:05
Show Gist options
  • Save mbcarruthers/92192bc5ee47b086ec3033da9f7bfa3a to your computer and use it in GitHub Desktop.
Save mbcarruthers/92192bc5ee47b086ec3033da9f7bfa3a to your computer and use it in GitHub Desktop.
let array1 = [1,2,3,9];
let array2 = [1,2,4,4];
//make a program that goes through each of these arrays and can
//return to you whether 2 numbers add to equal 8
for(let i = 0;i<array2.length;i++) {
for(let j = 0;j < array2.length;j++) {
if(array2[i] + array2[j] === 8) {
console.log(array2[i] + ' and ' + array2[j] +' add to equal 8');
} else {
console.log(i + ' and ' + j + ' do not equal 8 ');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment