Skip to content

Commit 93e38a5

Browse files
committed
Class
1 parent dc91021 commit 93e38a5

File tree

17 files changed

+256
-1
lines changed

17 files changed

+256
-1
lines changed

45. Arrow Function/index.html

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@
66
<title>Document</title>
77
</head>
88
<body>
9-
9+
<h1>Formulir pendaftaran SMK Wira Buana</h1>
10+
<label for="">Masukkan Nama Siswa/i Anda</label>
11+
<input type="text" name="" id=""><br>
12+
<label for="">Masukkan Umur Anda</label>
13+
<input type="number"><br>
14+
<button type="submit">Submit</button>
15+
16+
17+
1018
<script src="main.js"></script>
1119
</body>
1220
</html>

46. Shuffle An array/index.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document</title>
7+
</head>
8+
<body>
9+
10+
<script src="main.js"></script>
11+
</body>
12+
</html>

46. Shuffle An array/main.js

+7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
let cards = ["A", "2", "3", "4","5","6","7","8","9","10","J","Q","K"]
22

33
shuffle(cards)
4+
cards
5+
.forEach((x) => console.log(x))
46

57
function shuffle (array){
68
let currenindex = array.length
79

810
while(currenindex != 0){
911
let randomindex = Math.floor(Math.random() * currenindex)
1012
currenindex -= 1
13+
14+
let temp = array[currenindex]
15+
array[currenindex] = array[randomindex]
16+
array[randomindex] = temp
1117
}
18+
1219
}

47. Nested Function/index.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document</title>
7+
</head>
8+
<body>
9+
10+
<script src="main.js"></script>
11+
</body>
12+
</html>

47. Nested Function/main.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
let username = "Bro"
2+
let userinbox = 0
3+
4+
login()
5+
function login(){
6+
displayUserName()
7+
displayUserInboX()
8+
9+
}
10+
11+
function displayUserName(){
12+
console.log (`Welcome ${username}`)
13+
}
14+
15+
function displayUserInboX(){
16+
console.log (`You Have ${userinbox} New Messages`)
17+
}

48. Map/index.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document</title>
7+
</head>
8+
<body>
9+
10+
<script src="main.js"></script>
11+
</body>
12+
</html>

48. Map/main.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Map = object that holds key-value parts of any data type
2+
3+
const store = new Map([
4+
["T-Shirt",20],
5+
["Jeans",30],
6+
["Socks",10],
7+
["Underwear",15]
8+
])
9+
10+
let shoppingcart = 0
11+
12+
// store.set("Hat", 40)
13+
// store.delete("Hat")
14+
// console.log (store.has("Underwear"))
15+
// console.log(store.size)
16+
17+
18+
store.forEach((x, y) => console.log(`You Buy some ${y} and the price is ${x}$`))

49. Object/index.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document</title>
7+
</head>
8+
<body>
9+
10+
<script src="main.js"></script>
11+
</body>
12+
</html>

49. Object/main.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Object = A Group of properties and methods
2+
// Properties = What an object has
3+
// methods = What an object can do
4+
// use . to access properties/methods
5+
6+
const car = {
7+
model:"Mustang",
8+
color:"red",
9+
year:2023,
10+
11+
drive : function(){
12+
console.log("You Drive that car")
13+
}
14+
}
15+
16+
const car2 = {
17+
model:"Lamborghini",
18+
color:"black",
19+
year:2019,
20+
21+
drive2 : function(){
22+
console.log(`You drive the ${this.model}`)
23+
}
24+
}
25+
26+
console.log(car2.model)
27+
console.log(car2.color)
28+
console.log(car2.year)
29+
30+
car2.drive()
31+
car2.brake()

50. This/index.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title></title>
7+
</head>
8+
<body>
9+
10+
11+
<script src="main.js"></script>
12+
</body>
13+
</html>

50. This/main.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// This = reference to a particular object
2+
// the object depends on the immediate context
3+
4+
const car = {
5+
6+
model:"Mustang",
7+
color:"red",
8+
year:2023,
9+
10+
drive : function(){
11+
console.log(`You Drive that ${this.model} car`)
12+
}
13+
}
14+
15+
const car2 = {
16+
model:"Lamborghini",
17+
color:"black",
18+
year:2019,
19+
20+
drive2 : function(){
21+
console.log(`You drive the ${this.model}`)
22+
}
23+
}
24+
25+
car.drive()
26+
car2.drive2()

51. Class/index.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document</title>
7+
</head>
8+
<body>
9+
10+
<script src="main.js"></script>
11+
</body>
12+
</html>

51. Class/main.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Class = a blueprint for creating objects
2+
// define what properties and methods they have
3+
// use a constructor for unique properties
4+
5+
class player{
6+
7+
score = 0
8+
9+
username = "Xtentacionz"
10+
11+
pause(){
12+
console.log ("You Paused the game")
13+
}
14+
15+
victory(){
16+
this.score += 1
17+
console.log(this.score)
18+
}
19+
}
20+
21+
let player1 = new player
22+
let player2 = new player
23+
24+
player1.victory()
25+
player2.pause()
26+

52. Constructor/index.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document</title>
7+
</head>
8+
<body>
9+
10+
<script src="main.js"></script>
11+
</body>
12+
</html>

52. Constructor/main.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Constructor = a special method of a class,
2+
// accepts arguments and assigns properties
3+
4+
class students{
5+
constructor(name,age,iq){
6+
this.name = name
7+
this.age = age
8+
this.iq = iq
9+
}
10+
study(){
11+
console.log (`${name} studying`)
12+
}
13+
14+
15+
}
16+
17+
let student1 = new students("Spongebob", 30, 150)
18+
19+
console.log (student1.name)
20+
console.log (student1.age)
21+
console.log (student1.iq)

53. Static Keyword/index.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document</title>
7+
</head>
8+
<body>
9+
10+
<script src="main.js"></script>
11+
</body>
12+
</html>

53. Static Keyword/main.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// static = belongs to the class, not the objects
2+
// properties: useful for cache, fixed=configuration
3+
// methods: useful for utility functions
4+

0 commit comments

Comments
 (0)