Skip to content

Commit 7345c34

Browse files
committed
update
1 parent 3e9d207 commit 7345c34

2 files changed

Lines changed: 89 additions & 0 deletions

File tree

07- function/demo.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//JavaScript function with out html
2+
//Code Drive Invocation
3+
function myFunction(fullName, age, dateOfBirth = 1991) {
4+
console.log('Hello ' + fullName + "I'm " + age + " years old. " + ' My date of birth ' + dateOfBirth + '.');
5+
}
6+
7+
myFunction('Sahin. ',20, 2000);
8+
myFunction('Enam. ',17, );
9+
10+
//function with html
11+
//Even Driven Invocation
12+
function isSubscribed() {
13+
console.log("Subscribed");
14+
}
15+
document.getElementById('btn').addEventListener('click', isSubscribed);
16+
17+
18+
//Automatic (Self-Invoked) Invocation
19+
(function () {
20+
console.log('I am Self-Invoked function')();
21+
})
22+
23+
24+
25+
//Use function in variable
26+
let maths = function(x, y) {
27+
return x * y;
28+
};
29+
console.log(maths (3,4));
30+
console.log(maths (50,8));
31+
32+
33+
//Arry
34+
let number = [2,3,4,5,8,90,100];
35+
let sqNumbers = number.map(function (number) {
36+
return number * number;
37+
})
38+
console.log(sqNumbers);
39+
40+
41+
42+
43+
let add = function (x,y) {
44+
return x + y;
45+
}
46+
console.log(add(5,6));
47+
48+
//Arrow function
49+
let add1 = (x,y) => x + y;
50+
console.log(add(6,90));
51+
52+
//Next state function
53+
function greet(firstName) {
54+
function sayHello() {
55+
alert('Hi ' + firstName);
56+
}
57+
return sayHello();
58+
}
59+
greet('Sahin Enam');
60+
61+

07- function/index.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<title>Demo</title>
8+
</head>
9+
<body>
10+
11+
<button id="btn">Subscribe</button>
12+
13+
14+
<script src="demo.js"></script>
15+
</body>
16+
17+
<style>
18+
button{
19+
background: red;
20+
padding: 20px 35px;
21+
color: white;
22+
font-size: 18px;
23+
border-radius: 10px;
24+
border: 0;
25+
}
26+
27+
</style>
28+
</html>

0 commit comments

Comments
 (0)