Created
February 6, 2020 16:20
-
-
Save sajadtorkamani/a8b32328387fc4c547c5cf1223f19f50 to your computer and use it in GitHub Desktop.
Find min example
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
// The counter implementation to the weird function! | |
const solution = n => { | |
let result = []; | |
for (let num = 1; num <= n; num++) { | |
result.push(num); | |
} | |
return result; | |
}; | |
// The weird function | |
function find_min(A) { | |
var ans = 0; | |
for (var i = 1; i < A.length; i++) { | |
if (ans > A[i]) { | |
ans = A[i]; | |
} | |
} | |
return ans; | |
} | |
console.log(solution(6)); | |
console.log(find_min(solution(6))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment