Saturday, April 1, 2017

Learn JavaScript V (function)

edankeun.com-learn function JS, what's function? function is a block of code and can be used for particular time,if you want to call some code repeatedly without rewrite new code in every line, you should use function

1.Basic Function
here's is basic how to write or create function in JS(JavaScript)
we will create example how to call Text "Hello World " with function

*** ***
you can calling the function as many as you want

<script>
function hello(){
  document.write("Hello World");
}
hello();
//your code here
hello();
hello();
</script>

this code will print

Hello World
Hello World
Hello World

2.Function Parameters
function can use parameter as many as you want

function yourfunct(param1,param2,param3){
//Code Here
}

using parameters example


** **

Multiple Parameters
multiple parameters use if you have two or both parameters with different variable, separate by comma
Example
** **

3.Return Value
a function usually have a return statement, return is use if your function want to return value or give a value
the return function is useful if you want to make calculation

for example

** **
that function will print "15" that result is give from the function addFunct,when you give a parameter
10 and 5, it will replace variable (a,b)

4.Alert Box
alert box is use when you want to show the popup on your executed code, as well as can be improve with conditional, looping, and function
if you want to show popup when the number is more than 10, you can use if else condition and alert function

example

Alert("This is Your Alert | edankeun");


you just learned about Function in JavaScript as well as you can explore whats is function on Google Site,but everything is start from zero, if you don't know a basic first you will not understand about function in complex section

if you enjoy with this article you can share and comment on this post bellow, we are so glad if you want discuss about this topict

Keep Cheers and Simply

Edankeun.com

Related Posts

Learn JavaScript V (function)
4/ 5
Oleh