+ 2
Whatâs wrong with my JavaScript code?
I am trying to solve a javaScript pro question in the course and it wants me to return the average of three numbers. My code runs in every browser on earth but in this app it says âno outputâ, when the output is clearly 6. Itâs driving me crazy. Please help I need the xp XD. function average (a, b, c) { var avg = (a + b + c) / 3; return avg; } average (3,6,9); https://code.sololearn.com/c32tSH5B3PKg/?ref=app https://code.sololearn.com/WZRctn3nns3C/?ref=app
4 Answers
+ 3
You are writing your JavaScript code inside Java, please look into that.
+ 3
Cristina Éuá´Ęsá´ÉšĆ you must log the output.
var result = average (3,6,9);
console.log(result)
OR
console.log(average (3,6,9));
0
Cristina Éuá´Ęsá´ÉšĆ Java and JavaScript are two different languages. Select web or node.js if you want to write code using JavaScript, when coding on SoloLearn Playground/Code.