-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.js
More file actions
20 lines (17 loc) · 1.36 KB
/
function.js
File metadata and controls
20 lines (17 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// একই কাজ বার বার করার জন্য আমরা সেইম কোড বার বার না করে শুধু একটা ফাংশনে লিখে তা অনেক জায়গায় ব্যবহার করতে পারি।
function greeting(){
console.log("Good Morning !!!")
}
greeting();
// ফাংশনের ভিতরে একাধিক কোড লিখার পর অনেক সময় কল করতে গেলে রেজাল্ট আন্ডিফাইন্ড দেখায় এই সিচুয়েশন হ্যান্ডেল করতে return ব্যবহার করতে হবে।
function hi(){
return "Hello EveryOne!"
}
console.log(hi());
// ফাংশনের () এই চিহ্নে প্যারামিটার সেট করে সেই প্যারামিটারকে ফাংশনের ভিতরে কিছু একটা করে রিটার্নের মাধ্যমে পাস করা হয়। আর সেই ফাংশনকে বাহির থেকে ভ্যারিয়েবলের রেখে সেই ভ্যারিয়েবল কে কল করলে হয়।
function math (a, b){
const sum = a + b;
return sum;
}
const result = math(2, 2);
console.log(result);