Function Javascript - pptx-1
Function Javascript - pptx-1
JavaScript
Build, Parameter and Return
Table of Content
Functions are an important part of programming languages. Without realizing it, we actually used a
function in the previous code sample.
For Example…
alert('This is a message' );
Build Function
Another essential concept in coding is functions, which allow you to store a piece of code that does
a single task inside a defined block, and then call that code whenever you need it using a single
short command — rather than having to type out the same code multiple times.
Code…
function displayMyScore() {
// Code……
}
Build Function
Let's Code…
Parameter Function
Some functions require parameters to be specified when you are invoking them
If you're writing a function and want to support optional parameters, you can specify default values
by adding = after the name of the parameter, followed by the default value:
Let's Code…
Return Function
Return values are just what they sound like — the values that a function returns when it completes.
Example
Cheers
🍻