Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 202393c

Browse files
Update 07_Functions.md
1 parent d1d9faf commit 202393c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

‎07_Functions.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,32 @@ printWithDateAndTime();
6666

6767
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).
6868

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+
6995
[Back to course outline](https://github.com/mbarsott/LearnProgrammingWithJavascript/blob/master/README.md#learn-programming-with-javascript)
7096
7197
[Previous Page](https://github.com/mbarsott/LearnProgrammingWithJavascript/blob/master/06_IOandHelloWorld.md#io-and-hello-world)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /