-
Notifications
You must be signed in to change notification settings - Fork 0
/
tut10.js
46 lines (34 loc) · 1.47 KB
/
tut10.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
console.log('Welcome to Function Tutorial :- ');
//FUNCTION :- function is a block of code which is designed to repeat a particular task without writint too many line of codes.
function birthdayWishes(name , thanks) {
console.log(`They say ${name} you lose your memory as you grow older. I say forget about the past and live life to the fullest today. Start with cake. Happy birthday ${thanks}`)
}
birthdayWishes('Ahmar' , 'thanks a lot');
// * we add a default value
// * pass multiple parameter
// function none(name , class, greeting , branch);
/* function greet (name , thanks = 'Thankyou')
{
console.log(`They say ${name} you lose your memory as you grow older. I say forget about the past and live life to the fullest today. Start with cake. Happy birthday ${thanks}`)
// we want to return anything
return 0;
let val = birthdayWishes(name);
console.log(val);
}
*/
// * ek variable ko hm function me bhi dal sakte hai jaise |
// const mygreet = function(name , thankyou )
// where const is my data type where i study previously
// ek object ke andar bhi function ko bna sakte hai
const obj1 = {
name: 'SkillF',
game: function(){
return 'GTA';
}
}
console.log(obj1.game());//here is a demonstration
arr = ['fruit' , 'vegetable' , 'furniture'];
arr.forEach(function(element , index , array) {
console.log(element , index)//generally hm array iteration me print karte hai
});
// SCOPE:-