map, filter & reduce  Namaste JavaScript Ep. 19

map, filter & reduce Namaste JavaScript Ep. 19

Akshay Saini

2 года назад

857,992 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@ramdey6155
@ramdey6155 - 17.09.2021 13:18

Hi Aksahy, I am so grateful to you... You make my javascript concepts so clear that , I got offer from 5 companies and going to join a good company with 110% hike.
I really believe your content is worth payable. Thank you so much 🙌🙌🙌🙌
Keep educating and spreading love and knowledge. 🥳🥳🥳

Ответить
@sandeepkundekar
@sandeepkundekar - 19.12.2023 09:11

const output=arr.reduce((acc,curr)=>
{
if(curr.age<30)
{
acc.push(curr.first_name)
}
return acc
},[])

Ответить
@sachinchandran1118
@sachinchandran1118 - 18.12.2023 21:28

const output = users.reduce(function(acc, curr){
if(curr.age < 30){
acc.push(curr.firstName);
}
return acc
},[])


console.log(output)

Ответить
@colinthomas8454
@colinthomas8454 - 18.12.2023 21:08

const users =[{firstName:'colin',lastName:'CThomas',age:21},
{firstName:'Virat',lastName:'Kohli',age:20},
{firstName:'Cristiano',lastName:'Ronaldo',age:20}
]
const value=users.reduce( (acc,cur) =>{
if(cur.age>20)
{
acc.push(cur.firstName)
}
return acc
},[])

Ответить
@tanmaithungathurthy1536
@tanmaithungathurthy1536 - 17.12.2023 17:48

const users = [{firstName:"akshay" ,lastName:"saini",age:26},
{firstName:"donald" ,lastName:"trump",age:75},
{firstName:"elon" ,lastName:"musk",age:50},
{firstName:"deepika" ,lastName:"padukone",age:26}
];
const output=users.reduce(function(acc,curr)
{
if(curr.age<30)
{acc.push(curr.firstName);
}
return acc;
},[]);
console.log(output);

Ответить
@saitej22
@saitej22 - 17.12.2023 09:56

const users = [
{
name : "Sai",
age : 23
},
{
name : "siri",
age : 22
},
{
name : "guna",
age : 20
},
{
name : "kiran",
age : 21
},
{
name : "joel",
age : 19
}
];

const output = users.reduce((acc,curr) => {
if(curr.age > 21){
acc.push(curr.name)
}
return acc
},[])

console.log(output)

Ответить
@mahdiandalib186
@mahdiandalib186 - 17.12.2023 08:04

thx man

Ответить
@Manishkumar-pl5kt
@Manishkumar-pl5kt - 17.12.2023 00:06

Printing full name

let persons =[
{ fname :"Manish" , lname :"Kumar" , age:27},
{ fname :"Ranjeet" , lname :"Kumar" , age:26},
{ fname :"Abhimanyu" , lname :"Kumar" , age:22},
{ fname :"Raj" , lname :"Kumar" , age:27},
{ fname :"Rakesh" , lname :"Kumar" , age:22}
]


// Print the full name which has age > 25

// short form : solution 1
let output = persons
.filter(x=>x.age>25)
.reduce((acc, curr) =>{
acc.push([curr.fname ,curr.lname].join(' '))
return acc
},[])
console.log(output)
// [ 'Manish Kumar', 'Ranjeet Kumar', 'Raj Kumar' ]

// other way : solution 2

function getAge(item){
return item.age>25
}

let filterArr= persons.filter(getAge)

let reduceArr = filterArr.reduce((acc, curr)=>{
acc.push([curr.fname, curr.lname].join(" "))
return acc
},[])

console.log(reduceArr)

Ответить
@user-op3sj6op5y
@user-op3sj6op5y - 16.12.2023 08:08

My solution to the home work :
const users = [
{ firstName: "akshay", lastName: "saini", age: 26 },
{ firstName: "donald", lastName: "trump", age: 75 },
{ firstName: "elon", lastName: "musk", age: 50 },
{ firstName: "déepika", lastName: "padukone", age: 26 },
];
// ("akshay", deepika]]
const output = users.reduce(function (acc, curr) {
if (curr.age < 30) {
acc.push(curr.firstName);
}
return acc;
}, []);
console.log(output);

Ответить
@bm9code
@bm9code - 15.12.2023 09:29

waiting next videos

Ответить
@bm9code
@bm9code - 15.12.2023 09:28

users.reduce((arr, cur)=>{
if(cur.age<30) arr.push(cur.firstName);
return arr;
});

Ответить
@tejdoshi1502
@tejdoshi1502 - 14.12.2023 13:05

let challengeOutput = users.reduce(function(acc,curr){
if(curr.age<30){
acc.push(curr.firstName)
}
return acc;
},[]);

Ответить
@maugarcia2661
@maugarcia2661 - 13.12.2023 22:53

const users = [
{firstName: "akshay", lastName: "saini" , age: 26},
{firstName: "donald", lastName: "trump" , age: 75},
{firstName: "elon", lastName: "musk" , age: 50},
{firstName: "deepika", lastName: "padukone" , age: 26},
]

const output = users.reduce((acc, user)=> {
user.age > 30 && acc.push(user.firstName)
return acc

}, [])



console.log(output)

Ответить
@user-rq1nt2qo9b
@user-rq1nt2qo9b - 13.12.2023 13:59

Loved it😍

Ответить
@tarunbhadauria9075
@tarunbhadauria9075 - 12.12.2023 12:02

const output = users.reduce((acc,curr)=>{if(curr.age<30){acc.push(curr.firstName)}},[])

Ответить
@ashwaniashwani9665
@ashwaniashwani9665 - 12.12.2023 10:18

const output = users.reduce((acc, curr) => {
if (curr.age > 30) {
acc.push(curr.firstName);
}
return acc;
}, []);

Ответить
@nandakumart2331
@nandakumart2331 - 11.12.2023 16:34

let res=arr.reduce((acc,cv)=>{
if(cv.age<24){
acc.push(`${cv.firstName} ${cv.lastName} is ${cv.age} year old`)
}
return acc
},[])

Ответить
@alialshaches6658
@alialshaches6658 - 11.12.2023 01:07

good shit brother, good video

Ответить
@aniketroy03
@aniketroy03 - 10.12.2023 21:43

reduce is beautiful

Ответить
@chinmayjain9705
@chinmayjain9705 - 10.12.2023 15:57

const name = user.reduce((acc,curr)=>{
if (curr.age < 30) {
acc.push(curr.Name);
}
return acc;
}, []);
console.log(name);

Ответить
@irfan79760
@irfan79760 - 10.12.2023 10:33

H.W:
const ans= obj.reduce((acc, curr)=> {
if(curr.age >= 21){
acc.push(curr.firstname);
}
return acc;
},[])

Ответить
@anulmehta1175
@anulmehta1175 - 10.12.2023 08:06

find the users First Name that has age is less than 30 ? and Ans =>
const output=users.reduce(function(acc,curr){
if(curr.age<30){
acc.push(curr.firstName)
}
return acc
},[])
console.log(output);

Ответить
@khanasif1654
@khanasif1654 - 08.12.2023 16:31

const rdi= users.reduce((acc,curr)=>{



curr.age<30?acc.push(curr.firstname):0;
return acc



},[])

console.log(rdi)

Ответить
@nikitakarangle8806
@nikitakarangle8806 - 07.12.2023 13:41

const user = [
{ firstName: 'Eden', lastName: 'Hunter', age: 34 },
{ firstName: 'Bud', lastName: 'Foster', age: 21 },
{ firstName: 'Herbert', lastName: 'Allen', age: 56 },
{ firstName: 'Derick', lastName: 'Nichols', age: 34 },
{ firstName: 'Urban', lastName: 'Mack', age: 10 },
];

const output = user.reduce((acc, curr) => {
if (curr.age < 30) {
acc.push(curr.firstName);
}
return acc;
}, []);

console.log(output);

Ответить
@cr7_fan581
@cr7_fan581 - 07.12.2023 00:03

This is my homework
/***************************/
const output = arr.reduce(function (acc, cur) {
if (cur.age < 21) {
acc.push(cur.firstname);
}
return acc;
}, []);

/***************************/

Ответить
@vidushikagupta2900
@vidushikagupta2900 - 05.12.2023 11:18

Hi Akshay Sir Thank you for sharing your knowledge I was so confused about the concepts and pull my hairs like how the things done but with your way of teaching and your support make me fall in love with the javascript and now I understand the concepts way better than before . Thank you Thank you Thank you Thank you Thank you Thank you a big Thank you for sharing your knowledge with us.

Ответить
@funnygamesaadu1243
@funnygamesaadu1243 - 29.11.2023 10:36

const firstName = user.reduce((acc, curr) => {
if (curr.age < 30) {
acc.push(curr.firstname);
}
return acc;
}, []);

Ответить
@aigulidrisova1126
@aigulidrisova1126 - 27.11.2023 00:50

const output=arr2.reduce((acc,curr)=>{
if(curr.age<30){
acc.push(curr.firstName)
}
return acc
},[])

Ответить
@mayurchavan5811
@mayurchavan5811 - 26.11.2023 14:53

Thank you so much.

Ответить
@nimishareddy8488
@nimishareddy8488 - 24.11.2023 04:57

//using reduce
const fnRedyce = users.reduce((acc,curr) => {
if(curr.age<30){
acc=acc + curr.firstName
}
},[])
console.log('age<30 using reduce',fnAgeLessThan30);

Ответить
@VishalSharma-rn7mt
@VishalSharma-rn7mt - 22.11.2023 05:58

@akshaymarch7 solution for finding firstname with age < 30 using reduce
const firstName = users.reduce((acc, curr) => {
if (curr.age < 30) {
acc.push(curr.firstName);
}
return acc;
}, []);

Ответить
@AniketKumar-fo4lc
@AniketKumar-fo4lc - 16.11.2023 13:27

const users = [
{first:'aniket',age:22},
{first:'aniket1',age:33},
{first:'aniket2',age:22},
{first:'aniket3',age:55},
{first:'aniket3',age:55},
{first:'aniket4',age:65},
]

// const ans = users.reduce((acc,curr)=>{
// if(acc[curr.age]){
// acc[curr.age]++;
// }
// else{
// acc[curr.age]=1;
// }
// return acc;
// },{})

const ans = users.reduce((acc,curr)=>{
if(curr.age >10){
acc.push(curr.first)
}

return acc;
},[])

console.log(ans)

Ответить
@rahulxtremegaming7294
@rahulxtremegaming7294 - 14.11.2023 14:14

const output = arr.reduce((names, currentItem) => {
if(currentItem.age < 30) {
names.push(currentItem.firstName);
}
return names;
},[])

Ответить
@netrahindocha8423
@netrahindocha8423 - 13.11.2023 19:06

const output = users.reduce(function (acc, curr) {
if(curr.age < 30) {
acc.push(curr.firstName);
}
return acc;
}, [])

console.log(output);

Ответить
@saicharan4081
@saicharan4081 - 11.11.2023 19:14

This is the first video i have seen in your channels. I just printed this topics in my mind . Thank you boss .

Ответить
@prashantyallatti7780
@prashantyallatti7780 - 10.11.2023 20:36

With Reduce Function

Code-------------------------

let output = users.reduce((acc, curr) => {
if (curr.age < 25) {
acc.push(curr.firstName)
}

return acc
}, [])

console.log(output)

Ответить
@rakshandamadan4472
@rakshandamadan4472 - 10.11.2023 20:19

const output = user.reduce((acc , curr)=>{
if (curr.age < 30){
acc = curr.firstname
}

return acc;
},[])

console.log(output);

Ответить
@GauravSharma-zj8tb
@GauravSharma-zj8tb - 10.11.2023 13:53

arr.reduce((acc,curr)=>{ if(curr.age<30) acc.push(curr.firstname); return acc},[]);

Ответить
@softmerit25
@softmerit25 - 10.11.2023 10:19

Hey Man. You are so good. ❤ I love the way you pass detail explanations on your tutorials. Great job. Bless you

Ответить
@tamalbose2573
@tamalbose2573 - 10.11.2023 01:21

console.log("reduce return number: ", this.arr.reduce((prevVal, curVal, curIndex, a) => {
console.log("filter: ", prevVal, curVal, curIndex, a, this);
return prevVal;
}));

//prevVal, curVal, curIndex, a --------all these params pass in reduce, test to run above code

Ответить
@akhilchowdary814
@akhilchowdary814 - 09.11.2023 12:35

const ageGroup = users.reduce(function (acc, curr) {
if (curr.age <= 35) {
acc.push(curr.firstName);
}
return acc;
}, []);

console.log(ageGroup);

Ответить
@shravyakarnam5544
@shravyakarnam5544 - 08.11.2023 22:38

U got a subscriber bro...nice video

Ответить
@thecodeshetra4027
@thecodeshetra4027 - 08.11.2023 10:48

let userAge22Reduce = users.reduce((acc, current) =>{
if(current.age==22){
acc.push(current.name)
}
return acc
},[])

Ответить
@satyanarayanaveeravenkata6146
@satyanarayanaveeravenkata6146 - 06.11.2023 14:32

let outs = users.reduce((acc,x)=>{ (x.age<40?acc.push(x.firstName):null)
return acc
},[])

Ответить
@singhkr
@singhkr - 06.11.2023 06:31

const reduce=user.reduce((acc,curr)=>{
if(curr.age<34){
acc.push(curr.name)
}
return acc
},[])
console.log(reduce)

Ответить
@sudhanshusitole9116
@sudhanshusitole9116 - 06.11.2023 06:30

const users = [
{ firstName: "sudhanshu", age: 24, },
{ firstName: "shanu", age: 24, },
{ firstName: "himanshu", age: 26, }
]
const output = users.reduce(function (acc, curr) {
if (curr.age > 24) {
acc.push(curr.firstName)
}
return acc
}, [])
console.log(output);

Ответить
@satyam-seth
@satyam-seth - 05.11.2023 21:27

H.W.

users.reduce(function (acc, curr) {
if (curr.age < 30) {
acc.push(curr.firstName);
}

return acc;
}, []);

Ответить
@namanjain9552
@namanjain9552 - 05.11.2023 18:37

const output2=users.reduce(function(acc,curr){
if(curr.age<30){
acc.push(curr.firstname);
}
return acc
},[]);

Ответить
@TheNinjanOfficial
@TheNinjanOfficial - 05.11.2023 07:57

const output = user.reduce(function(acc, curr){
if (curr.age < 30){
acc.push(curr.firstName);
}
return acc;
}, [ ])

console.log(output);

Ответить