logo

Find the smallest Int

Given an array of integers your solution should find the smallest integer.


My code:

function findSmallestInt(arr) {
  				let smallestNumber = Infinity;  
  				for (let i = 0; i < arr.length; i++) {
    					if (arr[i] < smallestNumber) {
      						smallestNumber = arr[i];
    						}
  					}
  
 				 return smallestNumber;
				}
                    


And that's the best solution among all users:

function findSmallestInt(args) {
  				return Math.min(...args);
			}
                    

New things I learned today: