--------------------------map()--------------------------
// Adding xon to the end of every name
const children = ['Amir', 'Ali', 'Komila', 'Abbos', 'Aziz'];
let transformedNames = children.map(child => {
return child + 'xon'
})
console.log(transformedNames); // ['Amirxon', 'Alixon', 'Komilaxon', 'Abbosxon', 'Azizxon']
filter()
// --------------------------filter()--------------------------//
// Filter out teacher from students list.
const list = ['student1', 'student2', 'teacher', 'student3', 'student4', 'student5'];
let wantedPerson = list.filter(person => person === 'teacher')
console.log(wantedPerson) // ['teacher']
reduce()
// --------------------------reduce()--------------------------//
// Calculate the sum of the money to pay for dinner that was collected from your friends.
const money = [12000, 21000, 17500, 44000, 56000, 12500];
const collectedMoney = money.reduce((acc, perMoney) => {
return acc + perMoney;
});
console.log(`Collected money from your friends is "${collectedMoney}".`)
// Collected money from your friends is "163000".
forEach()
// --------------------------forEach()--------------------------//
// Greet with everyone
const people = ['Alisher', 'MalcolmX', 'Steve', 'Mike'];
let x = people.forEach(person => {
console.log(`Hello '${person}', How are you?`)
}); // =>
// Hello 'Alisher', How are you?
// Hello 'MalcolmX', How are you?
// Hello 'Steve', How are you?
// Hello 'Mike', How are you?
find()
// --------------------------find()--------------------------//
// Find the thieve
let crowd = ['person', 'person' , 'person', 'thieve', 'person', 'person', 'person' ];
const thieve = crowd.find(person => person === 'thieve');
console.log(thieve) // thieve
findIndex()
// --------------------------findIndex()--------------------------//
// Finding the Index of the First Odd Sock in Your Laundry Pile
let pile = ['pair', 'pair', 'pair', 'pair', 'pair', 'single', 'pair', ]
let foundItemIndex = pile.findIndex(sock => sock === 'single');
console.log(foundItemIndex) // 5
some()
// --------------------------some()--------------------------//
// Checking If Any of Your Friends Have Replied to Your Group Text About Dinner Plans
const replies = ['', '', '', 'Sure!', '']
const hasAnswer = replies.some(answer => answer !== '');
console.log(hasAnswer); // true
Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.
So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀
Top comments (0)