Last active
February 3, 2018 00:56
-
-
Save djorborn/5a93db101834b2265fd989f80c914121 to your computer and use it in GitHub Desktop.
JS Bin// source https://jsbin.com/qaxorop
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
// I want to see if array contains all of the numbers in arr; | |
var array = [0, 3, 7, 4, 2, 6]; | |
var win = [ | |
[0, 1, 2], | |
[3, 4, 5], | |
[6, 7, 8], | |
[0, 4, 8], | |
[2, 4, 6], | |
[0, 3, 6], | |
[1, 4, 7], | |
[2, 5, 8] | |
]; | |
function checkStuff(array, win){ | |
var nArr = []; | |
for(var i = 0; i < array.length; i++){ | |
for(var j = 0; j < win.length; j++){ | |
if( array[i] == win[j] ) { | |
nArr.push(array[i]) | |
} | |
} | |
} | |
return nArr; | |
} | |
for(var s = 0; s < win.length; s++){ | |
if(checkStuff(array, win[s]).length == 3){ | |
console.log(checkStuff(array, win[s])); | |
break; | |
} | |
} | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">// I want to see if array contains all of the numbers in arr; | |
var array = [0, 3, 7, 4, 2, 6]; | |
var win = [ | |
[0, 1, 2], | |
[3, 4, 5], | |
[6, 7, 8], | |
[0, 4, 8], | |
[2, 4, 6], | |
[0, 3, 6], | |
[1, 4, 7], | |
[2, 5, 8] | |
]; | |
function checkStuff(array, win){ | |
var nArr = []; | |
for(var i = 0; i < array.length; i++){ | |
for(var j = 0; j < win.length; j++){ | |
if( array[i] == win[j] ) { | |
nArr.push(array[i]) | |
} | |
} | |
} | |
return nArr; | |
} | |
for(var s = 0; s < win.length; s++){ | |
if(checkStuff(array, win[s]).length == 3){ | |
console.log(checkStuff(array, win[s])); | |
break; | |
} | |
}</script></body> | |
</html> |
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
// I want to see if array contains all of the numbers in arr; | |
var array = [0, 3, 7, 4, 2, 6]; | |
var win = [ | |
[0, 1, 2], | |
[3, 4, 5], | |
[6, 7, 8], | |
[0, 4, 8], | |
[2, 4, 6], | |
[0, 3, 6], | |
[1, 4, 7], | |
[2, 5, 8] | |
]; | |
function checkStuff(array, win){ | |
var nArr = []; | |
for(var i = 0; i < array.length; i++){ | |
for(var j = 0; j < win.length; j++){ | |
if( array[i] == win[j] ) { | |
nArr.push(array[i]) | |
} | |
} | |
} | |
return nArr; | |
} | |
for(var s = 0; s < win.length; s++){ | |
if(checkStuff(array, win[s]).length == 3){ | |
console.log(checkStuff(array, win[s])); | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment