FULL CODE + IMAGES + SLIDES @ http://blog.breakthru.solutions/learn...
PLAYLIST: • Learn Javascript with a SIMPLE Projec...
FOLLOW ME ON TWITTER: / thepowerslacker
FURTHER READING
Functions: https://developer.mozilla.org/en-US/d...
Math.random: https://developer.mozilla.org/en-US/d...
Math.floor: https://developer.mozilla.org/en-US/d...
Console.log:
FROM THE DOCS:
Generally speaking, a function is a "subprogram" that can be called by code external (or internal in the case of recursion) to the function. Like the program itself, a function is composed of a sequence of statements called the function body. Values can be passed to a function, and the function will return a value.
In JavaScript, functions are first-class objects, because they can have properties and methods just like any other object. What distinguishes them from other objects is that functions can be called. In brief, they are Function objects.
For more examples and explanations, see also the JavaScript guide about functions.
Description
Every function in JavaScript is a Function object. See Function for information on properties and methods of Function objects.
Functions are not the same as procedures. A function always returns a value, whereas a procedure might not.
To return a value other than the default, a function must have a return statement that specifies the value to return. A function without a return statement will return a default value. In the case of a constructor called with the new keyword, the default value is the value of its this parameter. For all other functions, the default return value is undefined.
The parameters of a function call are the function's arguments. Arguments are passed to functions by value. If the function changes the value of an argument, this change is not reflected globally or in the calling function.
Смотрите видео EXERCISE TWO: Write & Test Your First Function | Simple JS Project Training Tutorial онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Powerslacker 29 Ноябрь 2016, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 2,302 раз и оно понравилось 11 людям.