2

It my first post, i have some troubles with one javascript tutorial tasks. Yes i did research ;) Task is: 1. Generate array with 10 random numbers. 2. Make a function where aray will be argument 3. Function should return smallest number from array

I did something that works but i dont know how to connect second part in one function. Thanks in advance!

var tab = [] for (var i=0; i<10; i++) { var random = Math.floor(Math.random() * 59 + 1); tab.push (random); } function getMinFromTab(a,b) { return a - b; } tab.sort(getMinFromTab); getMinFromTab(tab); console.log(tab[0]); 
0

1 Answer 1

2
function min(array) { let min for (const value of array) { if (min === undefined || value < min) min = value } return min } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.