You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 07_Functions.md
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,6 +66,32 @@ printWithDateAndTime();
66
66
67
67
Well I guess you now have the knowledge needed to try the second exercise, under the [`Exercises/ex02` folder](https://github.com/mbarsott/LearnProgrammingWithJavascript/tree/master/Exercises/ex02).
68
68
69
+
## Returning values
70
+
71
+
A function can return a value to it's caller. This is done with the keyword `return`. Whenever javascript finds the keyword return it will stop executing the function and return to the point where the function was called. If the keyword `return` is followed by an expression, the result of the expression will be the value returned by the function. Try the following code in node.js:
72
+
73
+
```console.log(returnTitle())
74
+
console.log(returnHello());
75
+
console.log(returnWorld());
76
+
console.log(returnNothing());
77
+
78
+
function returnTitle() {
79
+
return 1;
80
+
}
81
+
82
+
function returnHello() {
83
+
return 'Hello';
84
+
}
85
+
86
+
function returnWorld() {
87
+
return 'World';
88
+
}
89
+
90
+
function returnNothing() {
91
+
return;
92
+
}```
93
+
94
+
69
95
[Back to course outline](https://github.com/mbarsott/LearnProgrammingWithJavascript/blob/master/README.md#learn-programming-with-javascript)
0 commit comments