0
I am following an example of a course and I was left with the doubt of why, in this code:
function area(largura, altura) {
const area = largura * altura;
if(area > 20) {
console.log(`Valor acima do permitido: ${area}m2.`);
} else {
return area;
}
};
console.log(area(5, 5));
After executed the result will also give undefined?
Valor acima do permitido: 25m2.
undefined
I know you have other better ways of doing this code, but I want to understand why undefined.
If the condition
if(area > 20)fortrue, what will be the return of the functionarea?– Woss