Skip to content
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

Changes #1147

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Changes #1147

Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 19 additions & 3 deletions week-2/01-async-js/hard (promises)/3-promise-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,34 @@
*/

function wait1(t) {

return new Promise((resolve) => {
setTimeout(() => {
resolve();
}, t * 1000);
});
}

function wait2(t) {

return new Promise((resolve) => {
setTimeout(() => {
resolve();
}, t * 1000);
});
}

function wait3(t) {

return new Promise((resolve) => {
setTimeout(() => {
resolve();
}, t * 1000);
});
}

function calculateTime(t1, t2, t3) {
const start = new Date().getTime();
return Promise.all([wait1(t1), wait2(t2), wait3(t3)]).then(() => {
return new Date().getTime() - start;
});

}

Expand Down
1 change: 1 addition & 0 deletions week-3/04-mongo-with-jwt-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@babel/plugin-transform-modules-commonjs": "^7.23.3",
"express": "^4.18.2",
"jest": "^29.7.0",
"jsonwebtoken": "^9.0.2",
"mongoose": "^8.0.3",
"supertest": "^6.3.3",
"ts-node": "^10.9.2"
Expand Down
10 changes: 8 additions & 2 deletions week-6/1-use-memo/src/components/Assignment1.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { useState } from "react";
import { useMemo, useState } from "react";

// In this assignment, your task is to create a component that performs an expensive calculation (finding the factorial) based on a user input.
// Use useMemo to ensure that the calculation is only recomputed when the input changes, not on every render.

export function Assignment1() {
const [input, setInput] = useState(0);
// Your solution starts here
const expensiveValue = 0;
const expensiveValue = useMemo(()=>{
let value =1
for(let i=1;i<input;i++)
value=value+i;
return value
},[input]);

// Your solution ends here

return (
Expand Down