1 function find_max(nums) {
2 let max_num = Number.NEGATIVE_INFINITY; // smaller than all other numbers
3 for (let num of nums) {
4 if (num > max_num) {
5 // (Fill in the missing line here)
6 }
7 }
8 return max_num;
0
0
function checkNumber(smallNumber) {
if (smallNumber === Number.NEGATIVE_INFINITY) {
return 'Process number as -Infinity';
}
return smallNumber;
}
console.log(checkNumber(-Number.MAX_VALUE));
// Expected output: -1.7976931348623157e+308
console.log(checkNumber(-Number.MAX_VALUE * 2));
// Expected output: "Process number as -Infinity"
Thank you!
0
0
Are there any questions left?
New questions in the section Javascript