+ 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

7th Jan 2021, 2:22 PM
Cristina ɐuᴉʇsᴉɹƆ
Cristina ɐuᴉʇsᴉɹƆ - avatar
4 Respuestas
+ 3
You are writing your JavaScript code inside Java, please look into that.
7th Jan 2021, 2:37 PM
Avinesh
Avinesh - avatar
+ 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));
7th Jan 2021, 6:51 PM
Avinesh
Avinesh - avatar
+ 1
Avinesh ODLNT Fixed. Still same “no output” message. Plus when the javaScript course asked me to do it, I wass doing it in web and still the same error.
7th Jan 2021, 6:41 PM
Cristina ɐuᴉʇsᴉɹƆ
Cristina ɐuᴉʇsᴉɹƆ - avatar
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.
7th Jan 2021, 5:18 PM
ODLNT
ODLNT - avatar