Functions
Md. Raihan Hossain Jibon
Posted on December 21, 2021
A Function is a way yo bundle code so that it can be reused. Functions allow us to run the same piece of code from multiple places in a program without having to copy paste the code repeatedly.
The Basic Anatomy of a function
The code between the curly brackets is called the function body.
Creating A Simple Function
Lets create a simple function. Enter the following code in the browser console.
Hello World!
const firstFunction = function () {
console.log("Hello World!);
}
Passing Arguments into Function
firstFunction just prints the same line of text every time you call it, but you will probably want your function to be more flexible than that. Function argument allow us to pass value and change to function behavior.
Lets create function with argument
const secoundFunction = function (name) {
console.log("Hello" + name "!");
}
We can send multiple argument also .
const secoundFunction = function (firstName, LastName) {
console.log("Hello" + firstName + LastName"!");
}
More Information Updating Soon.
Posted on December 21, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
October 4, 2023