diff --git a/firstToyProblems.js b/firstToyProblems.js new file mode 100644 index 0000000..2dedbd8 --- /dev/null +++ b/firstToyProblems.js @@ -0,0 +1,16 @@ +/** + * + * [1,10,5,-3,100] + * creat a function that finds the minimum + * without using any pre build in function + */ +function minimum(array) { + return; +} +let min = Number.MAX_VALUE; +for (let i = 0; i < array.length; i++) { + if (array[i] < min) { + min = array[i]; + return min; + } +} \ No newline at end of file diff --git a/minimumcode.js b/minimumcode.js new file mode 100644 index 0000000..30151a7 --- /dev/null +++ b/minimumcode.js @@ -0,0 +1,16 @@ +/** + * + * [1,10,5,-3,100] + * creat a function that finds the minimum + * without using any pre build in function + */ +function minimum(array) { + return; + let min = Number.MAX_VALUE; + for (let i = 0; i < array.length; i++) { + if (array[i] < min) { + min = array[i]; + return min; + } + } +} \ No newline at end of file