In this example I have a function named somar
which returns the sum of numA
and numB
and after that, the console shows me the result of the sum:
let somar = (numA, numB) => { //função anônima JS
console.log("Somando " + numA + " com " + numB);
return numA + numB;
}
var resultado = somar(10, 5);
console.log(resultado);
When I run this code, my output obviously is 15.
But how do I console.log
numA
and numB
?
When I tried to console log numA
and numB
my output is undefined
.
I just got the expected result when I used the console.log
inside the function as shown in the example. But how to do it outside?