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;
}
function findSmallestInt(args) {
return Math.min(...args);
}
New things I learned today: