This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const students = [ | |
{"name":"shoaib","age":20}, | |
{"name":"alex","age":10}, | |
{"name":"mehedi","age":5}, | |
{"name":"linda","age":12}, | |
{"name":"lilly","age":2}, | |
{"name":"william","age":1}, | |
] | |
let filter = students.map((student)=>{ | |
return student.name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const students = [ | |
{"name":"shoaib","age":20}, | |
{"name":"alex","age":10}, | |
{"name":"mehedi","age":5}, | |
{"name":"linda","age":12}, | |
{"name":"lilly","age":2}, | |
{"name":"william","age":1}, | |
] | |
let filter = students.find((student)=>{ | |
return student.name === "lilly" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const students = [ | |
{"name":"shoaib","age":20}, | |
{"name":"alex","age":10}, | |
{"name":"mehedi","age":5}, | |
{"name":"linda","age":12}, | |
{"name":"lilly","age":2}, | |
{"name":"william","age":1}, | |
] | |
students.forEach((student)=>{ | |
console.log(student); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const students = [ | |
{"name":"shoaib","age":20}, | |
{"name":"alex","age":10}, | |
{"name":"mehedi","age":5}, | |
{"name":"linda","age":12}, | |
{"name":"lilly","age":2}, | |
{"name":"william","age":1}, | |
] | |
let olderStudents = students.some((student)=>{ | |
return student.age > 15 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const students = [2, 7, 78, 9, 5] | |
let arrayContains = students.includes(7) | |
console.log(arrayContains); | |
// Expected output | |
// true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const app = express(); | |
app.get("/login", (req, res) => res.send("Already Logged in")); | |
app.post("/login", (req, res) => res.send("Logged in")); | |
app.listen(3000, () => console.log("server running on port 3000")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
// import rate limiter | |
const rateLimit = require("express-rate-limit"); | |
const app = express(); | |
// use ratelimiter into express | |
app.use( | |
// Configure rate limiter | |
rateLimit({ | |
windowMs : 5 * 60 * 1000, //limiting for 5 minutes | |
max : 5, //maximun request quota 5 in particular time limit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Bad practice | |
for(let i = 0; i < 50; i++){ | |
//do something | |
} | |
//Good practice | |
let NUMBER_OF_STUDENTS= 50 | |
for(let i = 0; i < NUMBER_OF_STUDENTS; i++){ | |
//do something | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// bad practice | |
const array = [ [ ['Shoaib Mehedi'] ] ] | |
array.forEach((firstArr) =>{ | |
firstArr.forEach((secondArr) => { | |
secondArr.forEach((element) => { | |
console.log(element); | |
}) | |
}) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// bad practice | |
const addSub = (a,b) => { | |
// add | |
const addition = a+b | |
// sub | |
const sub = a-b | |
// returning as a string | |
return `${addition}${sub}` | |
} |