Until now we didn’t worked with the return in functions. But there is a return in function
If we don’t write anything in return then it just return undefined. But we can return anything. Like – integer, string etc.
Let’s make our hand dirty by coding
Suppose in function we are going to two parameter. One is name and another is dialouge. Now we are going to print it on the console using return within a function
Now get the values from params first and put it inside a new variable. Now we are going to return this variable.
Now we need to change our function call. Because this function is not doing anything. It is returning something, we are going to catch the value and print it.
This step is a pretty easy to. Just initial a variable by calling the function
See the result in browser –
Can you write some functions now ?