https://developer.mozilla.org/ru/docs/Web/JavaScri...
function calculateFoodOrder(numAnimals = 0, avgFood = 0) {
if(Number.isInteger(numAnimals) && Number.isInteger(avgFood) && numAnimals > 0 && avgFood > 0 ) {
return numAnimals * avgFood;
}
return -1;
}
Короткая запись
const calculateFoodOrder = (n = 0, f = 0) => (Number.isInteger(n) && Number.isInteger(f) && n > 0 && f > 0 ? n * f : -1);
console.log(calculateFoodOrder()); // -1
console.log(calculateFoodOrder(-1,4)); // -1
console.log(calculateFoodOrder(1,3));//3
console.log(calculateFoodOrder([], 200)); // -1
console.log(calculateFoodOrder(Infinity, 200)); // -1