Created
October 10, 2017 15:48
-
-
Save aviwarner/f4031e7dfe6c432c810636698e611750 to your computer and use it in GitHub Desktop.
JS Bin Find Odd INT // source https://jsbin.com/luqorap
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 name="description" content="Find Odd INT"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
function findOdd(A) { | |
for (var i = 0; i < A.length; i++) { | |
var indexNumber = A.indexOf(A[i]); | |
var indexCount = 0; | |
while (indexNumber != -1) { | |
indexCount++; | |
indexNumber = A.indexOf(A[i], indexNumber + 1); | |
} | |
if (indexCount % 2 === 1) { | |
console.log(A[i]); | |
return A[i]; | |
} | |
} | |
} | |
findOdd([20,1,1,2,2,3,3,5,5,4,20,4,5]) | |
// ^ return 5 | |
findOdd([20,1,-1,2,-2,3,3,5,5,1,2,4,20,4,-1,-2,5]) | |
// ^ return 5 | |
findOdd([1,1,1,1,1,1,10,1,1,1,1]) | |
//^ return 10 | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">function findOdd(A) { | |
for (var i = 0; i < A.length; i++) { | |
var indexNumber = A.indexOf(A[i]); | |
var indexCount = 0; | |
while (indexNumber != -1) { | |
indexCount++; | |
indexNumber = A.indexOf(A[i], indexNumber + 1); | |
} | |
if (indexCount % 2 === 1) { | |
console.log(A[i]); | |
return A[i]; | |
} | |
} | |
} | |
findOdd([20,1,1,2,2,3,3,5,5,4,20,4,5]) | |
// ^ return 5 | |
findOdd([20,1,-1,2,-2,3,3,5,5,1,2,4,20,4,-1,-2,5]) | |
// ^ return 5 | |
findOdd([1,1,1,1,1,1,10,1,1,1,1]) | |
//^ return 10</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
function findOdd(A) { | |
for (var i = 0; i < A.length; i++) { | |
var indexNumber = A.indexOf(A[i]); | |
var indexCount = 0; | |
while (indexNumber != -1) { | |
indexCount++; | |
indexNumber = A.indexOf(A[i], indexNumber + 1); | |
} | |
if (indexCount % 2 === 1) { | |
console.log(A[i]); | |
return A[i]; | |
} | |
} | |
} | |
findOdd([20,1,1,2,2,3,3,5,5,4,20,4,5]) | |
// ^ return 5 | |
findOdd([20,1,-1,2,-2,3,3,5,5,1,2,4,20,4,-1,-2,5]) | |
// ^ return 5 | |
findOdd([1,1,1,1,1,1,10,1,1,1,1]) | |
//^ return 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment