DEV Community

Discussion on: Know more about function in JavaScript

 
codingtheworld777 profile image
codingTheWorld777

Oh sorry. Here is the link: repl.it/@doHoangKhanh121/StrikingU...

Thread Thread
 
sargalias profile image
Spyros Argalias • Edited

So in this program we're not receiving results or returning anything. We're only printing to the terminal because we use console.log.

Printing to the terminal and returning a result are separate things. One uses console.log and the other uses return.

In this program, we print to the screen on line 7 where we have console.log(${num} * ${i} = ${num * i})

But we never return anything, so on line 17, if we do:

const result = callback(); // this will always be undefined because we're not returning anything from inside callback()

For an example of how return works please see my previous reply :).

Hope that helps :)

Thread Thread
 
codingtheworld777 profile image
codingTheWorld777

Yep. That really helps me to know more about "return" in function. Thank you very much 🤗