JAVASCRIPT

https://odai1990.github.io/reading-notes/

JAVASCRIPT




img


Functions

Function is chunk of code that contain one statement or more to do specific task, also Function organize the code and prevents you from repeating yourself for ex: if you have task that you want to do it more than one time then you can add it to a function and call it when ever you want


Structure Of Function

any function you want to add you must follow this structure:
1. add function key word.
2. add name(best practice to be name refer to what function will do).
3. then open curly bracket and statements and close curly bracket.
call function just type functionName()


img


img


Declaring Function Need Information And Return Value


From Pictures below you will understand the mechanism


img



You can assign functions

var x=functionName()