Sorry for this very simple question but I can't seem to narrow down why the following functions return "undefined" for all results. This is my code:
function calculateTriangleArea(x, y){
x * y / 2
}
function calculateRectangleArea(x, y){
x * y
}
function calculateCircleArea(x){
Math.PI * x * x
}
if (calculateRectangleArea.name === true)
(function calculateRectangleArea(x, y)
{return [x * y]
})
if (calculateTriangleArea.name === true)
(function calculateTriangleArea(x, y){
return[x * y / 2]
})
else (function calculateCircleArea(x){
return [Math.PI * x * x]
})
when i run these 9 console.log commands it all returns undefined.
console.log(calculateRectangleArea(10, 5)); // should print 50
console.log(calculateRectangleArea(1.5, 2.5)); // should print 3.75
console.log(calculateRectangleArea(10, -5)); // should print undefined
console.log(calculateTriangleArea(10, 5)); // should print 25
console.log(calculateTriangleArea(3, 2.5)); // should print 3.75
console.log(calculateTriangleArea(10, -5)); // should print undefined
console.log(calculateCircleArea(10)); // should print 314.159...
console.log(calculateCircleArea(3.5)); // should print 38.484...
console.log(calculateCircleArea(-1)); // should print undefined
Aucun commentaire:
Enregistrer un commentaire