Created
June 8, 2017 00:17
-
-
Save mbcarruthers/78b488b91824f04b7503bfffbd84eee2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 this is longer and DOES NOT EQUAL 8'); | |
} | |
} | |
} | |
for(let i = 0;i<array1.length;i++) { | |
for(let j = 0;j < array1.length;j++) { | |
if(array1[i] + array1[j] === 8) { | |
console.log(array1[i] + ' and ' + array1[j] +' add to equal 8'); | |
} else { | |
console.log(i + ' and ' + j + ' do not equal 8, tTHIS IS LONGER AND DOES NOT EQUAL 8'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment