Why does this JavaScript code print “undefined” on the console?

牧云@^-^@ 提交于 2019-11-26 11:56:31

It's because the "printCounter()" function itself returns undefined. That's the console telling you the result of the expression.

Change "printCounter()" by adding return "Hello Anton!"; to the end :-)

edit — it's a little confusing to say it "returns undefined"; really, it has no explicit return, but it's the same effect.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!