Skip to content

Day 3 of 40 days of JavaScript #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 123 commits into
base: day-03
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
999864f
Merge pull request #5 from tapascript/day-03
atapas Feb 18, 2025
d93a747
(feat) Day 04 code and assignments
atapas Feb 20, 2025
a8cda36
day 05 changes
atapas Feb 23, 2025
503ebd6
Merge pull request #6 from tapascript/day-05
atapas Feb 23, 2025
7a3df0e
fix: typo
Refayth Feb 24, 2025
140edf0
Merge pull request #7 from Refayth/main
atapas Feb 25, 2025
013d9a4
(feat) Day 06 lesson
atapas Feb 26, 2025
2e6cfd4
bug fixes
atapas Feb 26, 2025
5aad8ca
Merge pull request #8 from tapascript/day-06
atapas Feb 26, 2025
c3cb7c9
Update README.md
atapas Feb 26, 2025
00ca37f
Update README.md
atapas Feb 26, 2025
7980924
Update README.md
atapas Feb 28, 2025
4602022
Update task.md
atapas Mar 1, 2025
07582b8
(feat) Day 07 projects
atapas Mar 1, 2025
15a30a5
Merge remote-tracking branch 'origin/main' into day-07
atapas Mar 1, 2025
e9fdb1e
(day 07) Updated readme
atapas Mar 1, 2025
18e403c
Merge pull request #9 from tapascript/day-07
atapas Mar 2, 2025
c2ba27d
(feat) Day 08
atapas Mar 4, 2025
e9f5380
Merge pull request #10 from tapascript/day-08
atapas Mar 4, 2025
7bca5d4
(feat) Day 09
atapas Mar 6, 2025
d53ccad
Merge pull request #11 from tapascript/day-09
atapas Mar 6, 2025
b03f92b
(fix) readme
atapas Mar 6, 2025
84c5f37
Merge pull request #12 from tapascript/day-09
atapas Mar 6, 2025
c55b690
(feat) Day 10 code and readme
atapas Mar 10, 2025
68b4c4a
(feat) day 10 - Tasks added
atapas Mar 10, 2025
133eb4e
Merge pull request #13 from tapascript/day-10
atapas Mar 10, 2025
40537d8
(feat) Day 11 Closure Done
atapas Mar 12, 2025
6b9c7d3
Merge pull request #14 from tapascript/day-11
atapas Mar 12, 2025
ef2e9d1
(feat) Day 12 done
atapas Mar 16, 2025
3ba9148
Merge pull request #15 from tapascript/day-12
atapas Mar 16, 2025
ed43d8c
Update index.js
atapas Mar 18, 2025
3e9202a
(feat) Day 13 this keyword
atapas Mar 19, 2025
7f80858
Merge pull request #16 from tapascript/day-13
atapas Mar 19, 2025
46a7863
day 14 code
atapas Mar 23, 2025
ac751c0
(feat) Live 01 code
atapas Mar 24, 2025
a2f90db
(feat) Live 01
atapas Mar 24, 2025
eb1acad
Merge pull request #17 from tapascript/live-01
atapas Mar 24, 2025
ee1a26f
Merge remote-tracking branch 'origin' into day-14
atapas Mar 24, 2025
12872c0
(feat) Added Day 14 Exception handling
atapas Mar 24, 2025
c144eb5
Merge pull request #18 from tapascript/day-14
atapas Mar 25, 2025
44494e7
(feat) Day 15 Array Course - Initial Commits
atapas Mar 27, 2025
76d2522
(day 15) Array Master course
atapas Mar 30, 2025
0b74f2c
Merge pull request #19 from tapascript/day-15
atapas Mar 30, 2025
9c91bf6
(day 15) checked
atapas Mar 30, 2025
8d8178a
Merge pull request #20 from tapascript/day-15
atapas Mar 30, 2025
c3af822
(day 15) updated readme
atapas Mar 30, 2025
7a0457d
Merge pull request #21 from tapascript/day-15
atapas Mar 30, 2025
c481cf4
(feat) Day 16 JavaScript Debugging
atapas Apr 2, 2025
a72d070
Merge pull request #22 from tapascript/day-16
atapas Apr 2, 2025
e94d8c2
(day 17) Introduction to DM
atapas Apr 3, 2025
59764c1
(project) Project assignment of module 2
atapas Apr 3, 2025
5ea325d
Merge remote-tracking branch 'origin/main' into day-17
atapas Apr 3, 2025
96136d2
Update task.md
atapas Apr 5, 2025
cc6d0ad
(Day 18) DOM Manipulations
atapas Apr 6, 2025
a66e21d
Merge remote-tracking branch 'origin/main' into day-18
atapas Apr 6, 2025
0054258
Merge pull request #23 from tapascript/day-17
atapas Apr 6, 2025
0f7eb8a
Merge remote-tracking branch 'origin/main' into day-18
atapas Apr 6, 2025
81c5370
Update README.md
atapas Apr 6, 2025
d222d48
Merge pull request #24 from tapascript/day-17
atapas Apr 6, 2025
2670689
(day 18) readme fixes
atapas Apr 7, 2025
5904d37
Update task.md
atapas Apr 8, 2025
19d483a
(day 19) JavaScript Events
atapas Apr 8, 2025
0e119bc
(day 18) DOM Manipulations
atapas Apr 8, 2025
02ddbb5
Merge branch 'day-18' into day-19
atapas Apr 8, 2025
a3581b2
(day 19) DOM Events
atapas Apr 8, 2025
e1b95d1
Merge pull request #25 from tapascript/day-18
atapas Apr 13, 2025
3a57b94
Merge pull request #26 from tapascript/day-19
atapas Apr 13, 2025
01f4cd0
(feat) Day 20 Advanced DOM
atapas Apr 16, 2025
ae7c03e
Merge remote-tracking branch 'origin/main' into day-20
atapas Apr 16, 2025
941177f
(feat) Day 20 - Added Tasks
atapas Apr 16, 2025
fa16453
Merge pull request #27 from tapascript/day-20
atapas Apr 16, 2025
a9ba600
(feat) day 21 - DOM Project
atapas Apr 28, 2025
9e3cfe3
Merge pull request #28 from tapascript/day-21
atapas Apr 28, 2025
d69ee00
(fix) day 21 link fix
atapas Apr 28, 2025
5cd2ddb
Merge pull request #29 from tapascript/day-21
atapas Apr 28, 2025
3ba265b
(feat) Day 22 - API Routes for PizzaHub
atapas Apr 29, 2025
fa6dc4d
(feat) Day 22 - Added the order POST api
atapas Apr 29, 2025
9574ba1
(feat) Day 22 - code doc
atapas Apr 30, 2025
e0548da
(feat) Day 22 - Code Committed
atapas Apr 30, 2025
337d5dd
(feat) Day 22 - Readme update
atapas Apr 30, 2025
ce00e58
(feat) Day 22 - Readme Update
atapas May 1, 2025
a581ab9
Merge pull request #30 from tapascript/day-22
atapas May 1, 2025
47c3d32
(feat) Day 23 - Added the promise example
atapas May 2, 2025
b455e4f
(fix) Day 23 - Refactor
atapas May 2, 2025
bb18d8b
(feat) Day 23 - Added delay
atapas May 2, 2025
19cd197
(feat) Day 23 - All updates
atapas May 3, 2025
0a3fa89
Merge pull request #31 from tapascript/day-23
atapas May 3, 2025
34f9cc4
(fix) Day 23 - fixed alignment
atapas May 3, 2025
12ef7ba
Merge pull request #32 from tapascript/day-23
atapas May 3, 2025
32d4837
(feat) Day 24 - pizzahub example
atapas May 5, 2025
b6e1953
(feat) Day 24 - async/await session
atapas May 7, 2025
1454c5e
Merge pull request #33 from tapascript/day-24
atapas May 7, 2025
87b63d6
Create LICENSE
atapas May 8, 2025
8932429
(feat) Day 25 - The fetch() API
atapas May 12, 2025
5a0c64e
(feat) day 25 - The fetch() API
atapas May 15, 2025
92893f7
(fix) Day 25 - fixed comments
atapas May 15, 2025
f92fb8d
(fix) Day 25 - comment fix
atapas May 15, 2025
f1dc916
Merge pull request #34 from tapascript/day-25
atapas May 15, 2025
9ec5fa2
(feat) Day 26 - Common Mistakes
atapas May 19, 2025
27a7cf8
Merge pull request #35 from tapascript/day-26
atapas May 19, 2025
c83f450
(feat) Day 27 Event Loop
atapas May 22, 2025
591f01f
(feat) LIVE LET's Code
atapas May 25, 2025
ad342fd
Merge pull request #37 from tapascript/live-lets-code
atapas May 25, 2025
74299c9
added live readme
atapas May 25, 2025
ada05f0
Merge pull request #36 from tapascript/day-27
atapas May 25, 2025
3a87bb6
Merge pull request #38 from tapascript/live-lets-code
atapas May 25, 2025
f797e47
Added inventory API
atapas May 25, 2025
972362d
Merge pull request #39 from tapascript/live-lets-code
atapas May 25, 2025
3c9f920
(feat) DAY 28 - Added country Explorer
atapas May 25, 2025
8351bf6
(feat) Day 28 - Country Project
atapas May 27, 2025
c321bca
Merge pull request #40 from tapascript/day-28
atapas May 27, 2025
5d38242
(feat) OOP Concept
atapas Jun 1, 2025
a766c7f
Merge pull request #41 from tapascript/day-29
atapas Jun 1, 2025
e5fa507
(feat) Day 30 - ES6 Classes
atapas Jun 5, 2025
3a21f82
Merge pull request #42 from tapascript/day-30
atapas Jun 6, 2025
d83f067
(feat) day 31 - Prototype and Prototype Chain
atapas Jun 7, 2025
fc63718
Merge pull request #43 from tapascript/day-31
atapas Jun 7, 2025
accb3b3
(feat) JavaScript Modules done
atapas Jun 10, 2025
b5c8f71
(feat) main readme update
atapas Jun 10, 2025
b8686e5
Merge pull request #44 from tapascript/day-32
atapas Jun 10, 2025
2ac569d
(feat) Day 33 Collections and Day 10 task bugfix
atapas Jun 12, 2025
4dd13dd
Merge pull request #45 from tapascript/day-33
atapas Jun 12, 2025
b281435
The above are the outcome of my assignment for 40
Pishon-P Jun 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
(feat) Day 23 - Added the promise example
  • Loading branch information
atapas committed May 2, 2025
commit 47c3d32af10feb510e01ab245bb281a929d5efd6
19 changes: 19 additions & 0 deletions day-23/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Promise - PizzaHub</title>
<script defer src="./lib/query.js"></script>
<script defer src="./index.js"></script>
</head>
<body>
<div>
<h1>PizzaHub - Order Here</h1>
<p id="store"></p>
<p id="order-details"></p>
<p id="add-on"></p>
<p id="order"></p>
</div>
</body>
</html>
57 changes: 57 additions & 0 deletions day-23/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Returns a shop id
let getShopIds = () => {
const url = `api/pizzahub`;
return query(url);
};

// Returns a promise with pizza list for a shop
let getPizzaList = (shopId) => {
const url = `api/pizzahub/pizzas/${shopId}`;
return query(url);
};

// Returns a promise with pizza that matches the customer request
let getMyPizzaWithAddOn = (pizzas, type, name) => {
let myPizza = pizzas.find((pizza) => {
return pizza.type === type && pizza.name === name;
});
const url = `api/pizzahub/beverages/${myPizza.id}`;
return query(url);
};

// Returns a promise after Placing the order
let performOrder = (result) => {
return query(`api/order`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
pizzaId: result.pizzaId,
beverageId: result.id,
}),
});
};

// Confirm the order
let confirmOrder = (type, name, createdAt) => {
console.log(
`Your order of ${type} ${name} has been placed at ${new Date(
createdAt
)}!`
);
};

function orderPizza(type, name) {
getShopIds()
.then((shopIds) => getPizzaList(shopIds[0]))
.then((pizzas) => getMyPizzaWithAddOn(pizzas, type, name))
.then((pizzaWithAddOns) => performOrder(pizzaWithAddOns[0]))
.then((order) => confirmOrder(type, name, order.createdAt))
.catch(function (error) {
console.log(`Bad luck, No Pizza for you today!`);
});
}

// Call the orderPizza method
orderPizza("veg", "Margherita");
10 changes: 10 additions & 0 deletions day-23/lib/query.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function query(endpoint, options) {
return fetch(`http://localhost:3000/${endpoint}`, options).then(
(response) => {
if (!response.ok) {
throw new Error(`HTTP error ${response.status}`);
}
return response.json();
}
);
}