-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path16_functions.js
59 lines (33 loc) · 1.18 KB
/
16_functions.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
47
48
49
50
51
52
53
54
55
56
57
58
59
// A JavaScript function is a block of code designed to perform a particular task.
// A JavaScript function is executed when "something" invokes it (calls it).
// function washingMachine() {
// console.log(`Hey there! your washu has started! i received your ${cloth} cloth and i am washing it! `);
// }
// washingMachine(4,4,5,6,7)
//a want to define a function to multipy two numbers:
// function addition(num1,num2,...allNum) {
// console.log(allNum);
// }
// addition(10, 20,10, 10,10,10,10,101,101,10)
//a want to pass an array inside my function:
// const students = ["tanvi", "shankar", "abhishek"];
// function studentFunction(studentsArr) {
// for (let i in studentsArr) {
// console.log(studentsArr[sportsTeacher] == "shankar");
// }
// }
// studentFunction(students)
//passing objects inside a function:
const obj = {
myName: "Yadnyesh",
rollNo: 10,
class:3
}
function passObj(object) {
// const name = object.myName
// const rollNumber = object.rollNo
const { myName:name,rollNo: rollNumber }=object
return `Helo! My name is ${name}. and my roll no is ${rollNumber}`
}
const str = passObj(obj)
console.log(str);