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. 🥳🥳🥳
@@akshaymarch7 bro where are you . Please do continue this series. I think there is no one explains the things like you. Please don't stop making videos.
@@akshaymarch7 hello akshay, I don't know whether you are active or not but please consider our request and upload few more videos on topics like async await, promises, spread and rest operators I believe only you can cover these topics with greater depth of understanding hopefully you're seeing this comment and wish I'd see your smile in upcoming videos this is 22k already thanks for spreading that amount of knowledge on youtube you're one of the reason I tell my juniors that you can learn anything from yt javascript se pyar to krva diya lekin is pyar ko manjil tk to pahucha do.
Hi Akshay, I just finished your "Namaste JavaScript - series 1" course. I can't say how much confident I am in JavaScript now just because of you. Thank you so much for making this amazing video series on JavaScript. Homework solution: const users = [ { firstName: "Akshay", lastName: "Saini", age: 26 }, { firstName: "Donald", lastName: "Trump", age: 75}, { firstName: "Elon", lastName: "Must", age: 50}, { firstName: "Deepika", lastName: "Padukone", age: 28} ]; const output = users.reduce(function(acc, curr) { if (curr.age < 30) { acc.push(curr.firstName); } return acc; } , [ ] ); console.log(output); P.S - from today onwards, I am naming you "The Amazing - Akshay Saini" Regards, Your Well-wisher and a learner
11:49 Found the answer for why reduce is named so. According to an article on digital ocean - "A reducer will only return one value and one value only hence the name reduce." In simple terms, it reduces the array to a single value.
// Code for the challenge given at 36:05 const outputlist = users.reduce((names, user) => { if(user.age < 30){ names.push(user.firstname); //can also use names.unlist(user.firstname); } return names; }, []);
Hi akshay. Today I have completed this season second time. I feel very confident in js fundamentals. while watching first time i cannot able to solve some the problem. Now I can able to solve. Thank you so much Akshay!! by using reduce const output = users.reduce(function(acc, curr){ if(curr.age
Hi, @@debo01 No, this will not work because you initialized the reduce function with object literals {}. Since we are pushing (.push) the results we should use an array for initialization, just like @Mohammad Noushad Siddiqui did. Thanks.
Hey Akshay 😍 I landed a fully front end position at Adobe. You are a gem Your tutorials were like a one place stop. I didn’t refer to any other documentation or tutorial. Made my life easy. Thank you so much ❤️❤️ This community is awesome because of people like you 🔥
first of all a very congratulations Akshaya ma'am , it will be a very kind of you if you may tell from where did u referred rest of the topics of this series , from where Akshay saini sir left this series ????
@@Abhishek_Poddar Could you tell me what you mean by rest of the topics? Interviews mostly cover the fundamentals. There were no targetted question based on syntax so in my view I think if you complete this playlist you can answer most interview questions on JS.
const names = users .reduce(function (acc, curr) { if (curr.age < 30) { acc.push(curr); } return acc; }, []) .map((x) => x.firstname); console.log(names); This is the homework.. Thank you sooo much. You explained the concepts very well.
All Episodes of Namaste JavaScript Web Series: ruclips.net/p/PLlasXeu85E9cQ32gLCvAvr9vNaUccPVNP ✅After watching this video, do let me know in the comment, How was the video? I read all the comments, would love your feedback! ❤️
@Akshay Saini Sir, Can you please make a video on a small project using all these concepts, with HTML CSS JavaScript, for beginners? So that we know where and how these concepts of your previous videos are used. I know that we can google the project, but your explanation is the best and we can understand all the concepts clearly. Only if it is possible and if it doesn't bother you to show a small project. Thankyou Sir. Please consider😊
Hats off to you Akshay for the Content. const output = users.reduce((acc, curr) => { if (curr.age < 30) { acc.push(curr.firstName) } return acc }, []);
Things learned: 1. map method is used when we want transformation of whole array. 2. filter is used when we want to filter the arrar to obtain required value. 3. reduce is used when we want to reduce the array to single value eg (max, min, avg, sum, difference etc). 4. reduce passes two arguments one function(which includes accumulator and initial value as argument itself) and another initial value of accumulator. 5. Homework: const output = user.reduce(function(acc, curr){ if (curr.age < 30){ acc.push(curr.firstName); } return acc; }, [ ]) console.log(output);
@@lakshyapant5225 Kyuki accumulator(acc) ki pehli condition me hi aapne return kar diya. Vo function se exit ho jaayega, aage ka process ruk gaya pura.
I know I'm already late for this but I have finally completed this JS tutorial today. It's just amazing and I don't have any words to describe and YES along with falling in love with JS, I fell in love with Akshay too 😊
Man your tutorials are so addictive, I don't want to study from other resources. You're like a good music band and we are fans that are waiting for new "songs". Please continue this awesome series 🙏🙏🙏
I regret for not finding your channel earlier :( still neva too late :) . So much clarity and that eager to make viewers understand the topic. Hats off. Thanks a lot.
@AkshaySaini bhai!!. Thank you so much for this must wanted series. Sorry, I might be late. But when you asked the question which method we will apply in array of object? I said (to myself ofcourse) Map & Reduce. You presented Reduce function. So, I tried with Map to prove correct to myself: (So, this is the answer for those folks who was thinking Map. ) const person = [ {firstName: "Deepanshu", LastName: "Jain", age: "27"}, {firstName: "Barack", LastName: "Obama", age: "52"}, {firstName: "Elon", LastName: "Musk", age: "52"}, {firstName: "Jeff", LastName: "Bezos", age: "41"} ] const op = {}; person.map(p => { if (op[p.age]) { op[p.age] = ++op[p.age]; } else { op[p.age] = 1; } }) console.log(op);
I'm a Nigerian who has been struggling to understand these concepts with some of my friends. I love how you add jokes and giffs while teaching. You just earned 12 subscribers(I and my 11 friends)
let results = names.reduce((acc,curr)=> { if(curr.age < 30) { acc.push(curr.firstname); } return acc; },[]) console.log(results); enjoyed watching your video. Thank you for creating such a nice video for us.
This should work. You don't need 2 return statements. let output = users.reduce((acc,curr) => { if(curr.age < 30) { acc.push(curr.firstName); } return acc; },[]);
Please continue this series sir ,as we want to learn more about things like promises , async-await , fetch api , OOPS in javascript and more on functional programming.
Here is my solution: const output = users.reduce(function(acc, curr){ if(curr.age < 30){ acc.push(curr.firstName); //if age of current user is < 30, push there firstName into the acc array } return acc; }, [ ]); //initially, the acc will be an empty array console.log(output); Thanks Akshay for such a crystal clear explanation!!
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.
11:50 - Name reduce was assigned with a purpose to maintain similarity between languages. We have similar reduce (and map, filter as well) in other languages also - Java, Python, Scala, Ruby etc. So having a consistent naming convention will be very easy for developers to get up and running when they switch from one language to another!
We can do something like this to get the desired output! const filterByAge = users.reduce((acc,item)=>{ if(item.age>30){ acc.push(item.firstName); } return acc },[])
Hi Akshay, really loved the whole Namaste Javascript Playlist, got to learn some really amazing stuff from you. Here is the code of the last question using reduce: const output = users.reduce(function (acc, curr) { if (curr.age < 30) acc.push(curr.firstName); return acc; }, []);
dude, you are a legend. I never saw anyone who explain a program the way you do. not just telling if you do this, this will happen, instead showing how it is happening. If you could upload the same way of teaching for other programs as well, it would be really amazing. I wouldn't mind to pay for such an golden content. also your smile really makes this course very enjoyable to watch. thankyou again
@@jahangagan5396 I like your answer jahan that is what I came up with. I don't really understand Omkar answer of acc = [...acc, curr.firstName]; why are we using spread syntax here
@jahan gagan Write a PURE function using map,filter and reduce methods to calculate the income tax given an amount. 0 upto 2.5L, 5% for 2.5L-5L, 20% for 5L-10L, 30% for more than 10L. Can you help me with this please
Akshay Sir, it's commendable that you are sharing the knowledge with everyone. You are an inspiration for all of us. Btw I did the homework. let data = users.reduce((acc,personDetails)=>{ if(personDetails.age < 30) acc.push(personDetails.name); return acc; },[]);
Thank you for such a nice content. Really clarified all my doubts with simple and advance examples. Home work completed sir. :) const output = users.reduce((acc, curr) => { if (curr.age < 30) { acc.push(curr.firstName); } return acc; }, []); console.log(output); @Akshay Saini, Can we expect videos on `Iterators` and `generators` in JS in near future ?
when will you release a video on the 'This' keyword in JS. We really need to understand how the binding of "this" is different in the arrow function !! BTW, great work till now!
Akshay Bhaiya , Please start a small course or a bootcamp for JS from basic concepts to advanced , this content is gold , we need more of your explanation in various concepts and functional concepts. #JSbyAkshaySaini
I was learning reduce from the video by coding myself and when I tried without assigning an initial value to the acc argument, the first element in the array was assigned to it automatically and the second element was assigned to the curr argument, just sharing an interesting fact, you are a great teacher ❤️❤️
If(curr.age < 30) { acc.push(curr.firstName); } return acc; /* Initialise "acc" as an empty array " [ ] " in 2nd paramter of the reduce function */ 35:50
Sir your contents are soooooooooo useful. It's really helped me to clearly understand map,reduce and filter thoroughly... Lot of love and Thank you ❤️❤️❤️
I am in more love with Javascript after watching "Namaste Javascript". I have shared it with all of friends and colleagues to strengthen their knowledge about JS. Words are not enough to explain the value of this series. Thanks for making this series for everyone with pure love and dedication ❤
On the contrary, name 'reduce' makes much sense to me since using arr.reduce() we are reducing the whole array to a single value...btw awesome explanation Akshay bhaiya
Below is another variation of *Example 9 - tricky map()* const users = [ { firstName: "Alok", lastName: "Raj", age: 23 }, { firstName: "Ashish", lastName: "Kumar", age: 29 }, { firstName: "Ankit", lastName: "Roy", age: 29 }, { firstName: "Pranav", lastName: "Mukherjee", age: 50 }, ]; const fullNameArr = users.map(({firstName, lastName, ...rest}) => { return { fullName: firstName + " " + lastName, ...rest, }; }); console.log(fullNameArr); In this code, the firstName and lastName properties are destructured from the user object, and the rest of the properties are collected into the rest object using the rest syntax (...rest). Then, a new object is returned with the fullName property and the properties from the rest object. This way, the firstName and lastName properties are not included in the new objects. The new array is then logged to the console. This way, the original users array remains unchanged.
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. 🥳🥳🥳
Congratulations, Ram 🎉
Wish you a great career ahead! ♥️
@@akshaymarch7 Thank you souch 😀
Just so you know, you are like that one friend who teaches entire subject few hours before exam 😎
@@akshaymarch7 bro where are you . Please do continue this series. I think there is no one explains the things like you. Please don't stop making videos.
@@akshaymarch7 hello akshay, I don't know whether you are active or not but please consider our request and upload few more videos on topics like async await, promises, spread and rest operators I believe only you can cover these topics with greater depth of understanding hopefully you're seeing this comment and wish I'd see your smile in upcoming videos this is 22k already thanks for spreading that amount of knowledge on youtube you're one of the reason I tell my juniors that you can learn anything from yt javascript se pyar to krva diya lekin is pyar ko manjil tk to pahucha do.
Hi Akshay,
I just finished your "Namaste JavaScript - series 1" course. I can't say how much confident I am in JavaScript now just because of you.
Thank you so much for making this amazing video series on JavaScript.
Homework solution:
const users = [
{ firstName: "Akshay", lastName: "Saini", age: 26 },
{ firstName: "Donald", lastName: "Trump", age: 75},
{ firstName: "Elon", lastName: "Must", age: 50},
{ firstName: "Deepika", lastName: "Padukone", age: 28}
];
const output = users.reduce(function(acc, curr) {
if (curr.age < 30) {
acc.push(curr.firstName);
}
return acc;
} , [ ] );
console.log(output);
P.S - from today onwards, I am naming you "The Amazing - Akshay Saini"
Regards,
Your Well-wisher and a learner
11:49
Found the answer for why reduce is named so. According to an article on digital ocean -
"A reducer will only return one value and one value only hence the name reduce."
In simple terms, it reduces the array to a single value.
// Code for the challenge given at 36:05
const outputlist = users.reduce((names, user) => {
if(user.age < 30){
names.push(user.firstname); //can also use names.unlist(user.firstname);
}
return names;
}, []);
can you please explain why you use [] instead of empty object {}
@@ShrikantKunte Thanks
because in the final output we need an array of first names of users whose age is less than 30
@@vidushikagupta2900
I also did the same broh
Hi akshay. Today I have completed this season second time. I feel very confident in js fundamentals. while watching first time i cannot able to solve some the problem. Now I can able to solve. Thank you so much Akshay!!
by using reduce
const output = users.reduce(function(acc, curr){
if(curr.age
Sir, Please complete Namaste Javascript series. This is a request on behalf of all javascript developers..
I complete the homework
const user = [
{ firstname: "Mohammad", lastname: "Noushad", age: 22 },
{ firstname: "Aniket", lastname: "Bhalla", age: 45 },
{ firstname: "Bidhi", lastname: "Chand", age: 21 },
{ firstname: "Saif", lastname: "Siddiqi", age: 67 },
];
const output = user.reduce((acc, current) => {
if(current.age < 30){
acc.push(current.firstname);
}
return acc;
}, []);
console.log(output);
const output = user.reduce((acc, curr) => {
if(curr.age < 30){
acc.push(curr.firstname);
}
return acc;
}, {}
);
Thanks akshay bro love you...
Hi, @@debo01 No, this will not work because you initialized the reduce function with object literals {}. Since we are pushing (.push) the results we should use an array for initialization, just like @Mohammad Noushad Siddiqui did.
Thanks.
@@debo01 no its wrong..you can't use push method to insert a data in object ,push is array 's method
How to put these first names into an object?
Hey Akshay 😍 I landed a fully front end position at Adobe. You are a gem Your tutorials were like a one place stop. I didn’t refer to any other documentation or tutorial. Made my life easy. Thank you so much ❤️❤️ This community is awesome because of people like you 🔥
first of all a very congratulations Akshaya ma'am , it will be a very kind of you if you may tell from where did u referred rest of the topics of this series , from where Akshay saini sir left this series ????
@@Abhishek_Poddar Could you tell me what you mean by rest of the topics? Interviews mostly cover the fundamentals. There were no targetted question based on syntax so in my view I think if you complete this playlist you can answer most interview questions on JS.
@venkyakshaya please let me know I want to see how you get opportunity in adobe and how can I get..?
const names = users
.reduce(function (acc, curr) {
if (curr.age < 30) {
acc.push(curr);
}
return acc;
}, [])
.map((x) => x.firstname);
console.log(names);
This is the homework..
Thank you sooo much. You explained the concepts very well.
I think there is no need to add map just change the code
acc.push(curr.firstName);
it justs only add firstname to acc
done with homework Akshay :)
const output=arr.reduce(function(acc,curr){
if(curr.age>15)
acc[curr.firstname]=curr.firstname;
return acc;
},{})
console.log(output);
All Episodes of Namaste JavaScript Web Series: ruclips.net/p/PLlasXeu85E9cQ32gLCvAvr9vNaUccPVNP
✅After watching this video, do let me know in the comment, How was the video? I read all the comments, would love your feedback! ❤️
Okay but your videos always awesome thnx
Please suggest me js book which helps me to learn js from beginner to pro and thanks for this beautiful video❤️
Video was amazing
Thanks bro
Please make video on arrow function and regular function
@Akshay Saini Sir, Can you please make a video on a small project using all these concepts, with HTML CSS JavaScript, for beginners? So that we know where and how these concepts of your previous videos are used. I know that we can google the project, but your explanation is the best and we can understand all the concepts clearly. Only if it is possible and if it doesn't bother you to show a small project. Thankyou Sir. Please consider😊
Super simple explanation
Hats off to you Akshay for the Content.
const output = users.reduce((acc, curr) => {
if (curr.age < 30) {
acc.push(curr.firstName)
}
return acc
}, []);
Things learned:
1. map method is used when we want transformation of whole array.
2. filter is used when we want to filter the arrar to obtain required value.
3. reduce is used when we want to reduce the array to single value eg (max, min, avg, sum, difference etc).
4. reduce passes two arguments one function(which includes accumulator and initial value as argument itself) and another initial value of accumulator.
5. Homework:
const output = user.reduce(function(acc, curr){
if (curr.age < 30){
acc.push(curr.firstName);
}
return acc;
}, [ ])
console.log(output);
bro agr mai return acc ko if k andrr likh rha hu toh error aa rhi hai so what's the reason behind it....please explain?
@@lakshyapant5225 Kyuki accumulator(acc) ki pehli condition me hi aapne return kar diya. Vo function se exit ho jaayega, aage ka process ruk gaya pura.
Amazing
I tried this homework directly in console but throwing error related to acc.push
@@ganeshbyale5024 Can you tell the error. Maybe i will be able to help you. Maybe copy paste your code and error
Home Work Solution:-
Ques:- To find firstName all the person whose age is less than 30.
const users = [
{firstName: "akshay", lastName: "saini", age: 26},
{firstName: "akshay", lastName: "saini", age: 75},
{firstName: "akshay", lastName: "saini", age: 50},
{firstName: "akshay", lastName: "saini", age: 26},
{firstName: "Roshini", lastName: "saini", age: 26},
{firstName: "Deepika", lastName: "saini", age: 26},
]
const output = users.reduce((acc, curr) => {
if(curr.age < 30) acc.push(curr.firstName)
return acc;
}, [])
PS: Please upvote if you like the solution.
I know I'm already late for this but I have finally completed this JS tutorial today. It's just amazing and I don't have any words to describe and YES along with falling in love with JS, I fell in love with Akshay too 😊
same😇🤩☺
Man your tutorials are so addictive, I don't want to study from other resources. You're like a good music band and we are fans that are waiting for new "songs". Please continue this awesome series 🙏🙏🙏
same here
Today I learnt 4 things from this video
1. Map function
2. Filter function
3. Reduce function
4. Deepika Padukon is still 26
Awesome video Akshay 👌👌👌
Hahaha 🤣
No she is not 26
i guess her age got "mapped" or "reduced" to 26. pun intended 😆😋
@@KPoireiNgambaSingha but you 'filtered' some years after 26 😂😂
kudos to Deepika😂😂
I regret for not finding your channel earlier :( still neva too late :) . So much clarity and that eager to make viewers understand the topic. Hats off. Thanks a lot.
const output = data.reduce((acc, curr) => {
if (curr.age > 30) {
acc.push(curr.name)
}
return acc;
}, [])
console.log(output)
Thank You Saree ♥ This vedio is amazing ...
@AkshaySaini bhai!!. Thank you so much for this must wanted series.
Sorry, I might be late.
But when you asked the question which method we will apply in array of object? I said (to myself ofcourse) Map & Reduce.
You presented Reduce function.
So, I tried with Map to prove correct to myself: (So, this is the answer for those folks who was thinking Map. )
const person = [
{firstName: "Deepanshu", LastName: "Jain", age: "27"},
{firstName: "Barack", LastName: "Obama", age: "52"},
{firstName: "Elon", LastName: "Musk", age: "52"},
{firstName: "Jeff", LastName: "Bezos", age: "41"}
]
const op = {};
person.map(p => {
if (op[p.age]) {
op[p.age] = ++op[p.age];
} else {
op[p.age] = 1;
}
})
console.log(op);
I'm a Nigerian who has been struggling to understand these concepts with some of my friends. I love how you add jokes and giffs while teaching. You just earned 12 subscribers(I and my 11 friends)
That’s 12 my friend 😂
@@hailea726 😂😂
@@hailea726 and you will all be forever in a friendship closure :)
Another 11 subscribers brother ( I and my 12 friends)
Another 12 subs( me and my other accounts)
You made this sooo simple to understand!! The reason why this playlist is soooooooo popular! Keep posting great contents.
Solution of the homework:
const output = users.reduce((prevVal, currVal) => {
if (currVal.age < 30) {
prevVal.push(currVal.firstName);
}
return prevVal;
}, []);
the thing is the output is not an array it doesn't have []
Exactly, that's the same thing i thought
@@abhisekgupta4678 you need only name so it make output in the form of array
@@mohitbansal321yh😊
const max30 = people.reduce((acc, curr) => {
if (curr.age > 30) {
// acc = curr.firstName;
acc = curr.firstName + " " + curr.lastName
}
return acc;
}, {});
console.log(max30)
let results = names.reduce((acc,curr)=>
{
if(curr.age < 30)
{
acc.push(curr.firstname);
}
return acc;
},[])
console.log(results);
enjoyed watching your video. Thank you for creating such a nice video for us.
Let output = user.reduce ( function (arr ,obj ){
if ( obj.age
Please cover the following topics:
1. async/await
2. Observables
3. Promise
Done in season 2
Solution for homework: let output = users.reduce((acc,curr) => {
if(curr.age < 30) {
acc.push(curr.firstName);
return acc;
} else {
return acc;
}
},[]);
console.log(output);
This should work. You don't need 2 return statements.
let output = users.reduce((acc,curr) => {
if(curr.age < 30) {
acc.push(curr.firstName);
}
return acc;
},[]);
@@RohitKumar-kk7fc Correct, i rectified the same.
How to get object instead of array?
@@thalhas9760 instead of pushing curr.firstName push curr
@@RohitKumar-kk7fc that's correct 👍
const output = users.reduce(function (acc , curr) {
if(curr.age
Homework done sir
let array = users.reduce((acc, crr) => {
if (crr.age < 30) {
acc.push(crr.firstName);
}
return acc;
}, []);
console.log(array);
I don't know but, after seeing notification from namaste javascript I got goosebumps 🔥 🔥, is that the same with everyone !
@@roshnis8552 yup
Exactlly bro ------------------- he is auper man :)
Yes yes yes....
Yes bro and you should have that goosebumps.
Please continue this series sir ,as we want to learn more about things like promises , async-await , fetch api , OOPS in javascript and more on functional programming.
I believe in Namaste Javascript supremacy! Akshay Saini for the president xD
🤐
Very easy and explanatory video. I am new to programming and watching your video has bought a lot of interest in me towards java script..:)
finally completed yhe whole playlist. Thanks Akshay for the great content.
Please cover the following topics:
1. async/await
2. Observables
3. Promise
Exactly.. Please cover those
Yes please!!!!
Yes Please ! Async/await, Observables and Promise..
yes please cover these topics also
go and check the Js mastery by harshith best course
Here is my solution:
const output = users.reduce(function(acc, curr){
if(curr.age < 30){
acc.push(curr.firstName); //if age of current user is < 30, push there firstName into the acc array
}
return acc;
}, [ ]); //initially, the acc will be an empty array
console.log(output);
Thanks Akshay for such a crystal clear explanation!!
const output2=users.reduce(function(acc,curr){
if(curr.age
Yeah, I have done the homework:
const output = persons.reduce((acc, currentVal) => {
if (currentVal.age < 30 ) acc.push(currentVal.firstname)
return acc;
}, [])
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.
Wow, congratulations to you. Keep rising! 🚀
is nameste js it enough to crack FE ?
let arr = [{fname: "first",age: 15},
{fname: "second",age:31}];
let output = arr.reduce((acc,curr)=>{
if(curr.age > 30){
acc.push(curr.fname)
}
return acc
},[]);
console.log(output);
Hi Akshay after submitted my answered then i am coming to others how they are answered
11:50 - Name reduce was assigned with a purpose to maintain similarity between languages. We have similar reduce (and map, filter as well) in other languages also - Java, Python, Scala, Ruby etc. So having a consistent naming convention will be very easy for developers to get up and running when they switch from one language to another!
also it reducing from multiple value(array) to single value
We can do something like this to get the desired output!
const filterByAge = users.reduce((acc,item)=>{
if(item.age>30){
acc.push(item.firstName);
}
return acc
},[])
but it would be good to use filter here
@@pranavparashar7137 surely, but that's not the point. The point is whether or not can we achieve the same functionality with reduce.
@@vinothkumarv9722 I love how you are trying to say you like Akshay more even when Deepika is having a crush on you✌
bro you can replace the if statement with this-
item.age>30 ? acc.push(item.firstName) : " "; return acc
ONE LINE OF CODE RIGHT !!!
@@divyansh50 sure we. Can do lie this condition rendering as well 😍
last assignment solution by using reduce
// 2. reduce
const result2 = users.reduce((acc, curr) => {
if (curr.age < 30) {
acc.push(curr)
}
return acc;
},[]).map(x => x.firstname)
console.log(result2);
Hi Akshay, really loved the whole Namaste Javascript Playlist, got to learn some really amazing stuff from you.
Here is the code of the last question using reduce:
const output = users.reduce(function (acc, curr) {
if (curr.age < 30)
acc.push(curr.firstName);
return acc;
}, []);
@Akshay Saini sir
assignment done
const output = user.reduce((acc, curr) => {
if(curr.age < 30) {
acc.push(curr.name);
}
return acc;
}, []);
console.log(output)
Nice 💯. Also you can use spread operator instead of push 😊
@@omkaranku1981 you can try acc=[...acc,curr.name] . Spread arr elements first and then the next argument should be the element you want to add.
@@mohit96nain but spread operator will create a deep copy everytime so its better to use .push()
@@omkaranku1981
const output = users.reduce((acc, user) => {
if (user.age < 30) return [...acc, user.firstName];
}, []);
Esses indianos sabem demais. Tu é doido! Salvando sempre. Namastê 🙏
Here's my solution using reduce
const output = users.reduce((result, {age, firstName}) => {
if(age < 30){
result.push(firstName);
}
return result;
}, []);
27:13 brought smile on my face even more interactive than my live lectures
let output=users.reduce(function(acc,curr){
if(curr.age
Can we please get a graphql and react series with this much depth your quality of course is far far good than those paid courses
dude, you are a legend. I never saw anyone who explain a program the way you do. not just telling if you do this, this will happen, instead showing how it is happening. If you could upload the same way of teaching for other programs as well, it would be really amazing. I wouldn't mind to pay for such an golden content. also your smile really makes this course very enjoyable to watch. thankyou again
Homework :
const output = users.reduce((acc, curr) => {
if(curr.age < 30){
acc.push(curr.firstName);
}
return acc;
}, []);
0:38 best intro I have ever seen in My life.. They way you said aayeee bsss bs bs 😂😂😂😂😂😂😂😂😂😂
After watch this video I got better understanding in map,filter,reduce Thank you so much
Best explanation for all this important array methods!!
Reduce example-
Const output=users.reduce((acc,curr) =>{
If(curr.age
Why not acc.push(curr.firstName)? XD
const output = users.reduce((acc, cur) => {
if (cur.age < 30) acc.push(cur.firstName)
return acc
}, [])
@@jahangagan5396 I like your answer jahan that is what I came up with. I don't really understand Omkar answer of acc = [...acc, curr.firstName]; why are we using spread syntax here
@@giannizamora7247 It is the another method of pushing elements into the array nothing else.
@jahan gagan Write a PURE function using map,filter and reduce methods to calculate the income tax given an amount. 0 upto 2.5L, 5% for 2.5L-5L, 20% for 5L-10L, 30% for more than 10L. Can you help me with this please
You're such an excellent teacher. PLEASE DON'T STOP
Akshay Sir, it's commendable that you are sharing the knowledge with everyone. You are an inspiration for all of us. Btw I did the homework.
let data = users.reduce((acc,personDetails)=>{
if(personDetails.age < 30) acc.push(personDetails.name);
return acc;
},[]);
Your statement "Filter function is actually used to filter" coincided with the Ad that starts with "So you wanna be a Software Engineer at Google".
lol
one of the best js tutorial and the way of teaching is great thanks sir
really fell in love with JS as promised in start of series .
Thank you for such a nice content. Really clarified all my doubts with simple and advance examples.
Home work completed sir. :)
const output = users.reduce((acc, curr) => {
if (curr.age < 30) {
acc.push(curr.firstName);
}
return acc;
}, []);
console.log(output);
@Akshay Saini, Can we expect videos on `Iterators` and `generators` in JS in near future ?
const output = users.reduce((acc, curr) => {
if (curr.age && curr.age < 30) {
acc.push(curr.firstName);
}
return acc;
}, []);
console.log(output);
Nice
const names = arr.reduce(function(acc, curr) {
if(curr.age < 30) acc.push(curr.firstName);
return acc
},[])
console.log(names)
@@saurabhgandhi615 what is thelogic of curr.age&&
Loved this JS series... The way you cover each topic is awesome... Easy to understand and remain forever. Thank you ❤️
Liked before watching whole video coz I know it's going to be great.
Was waiting for your new video, welcome back ♥️
Finally Season 2 Thank you so much bhaiya. 🙏 Bhot jyada help karte hai aap ke videos ❤
Brother - you are so natural in explaining these concepts! Big thanks 🙏
let belowFortyReduce = users.reduce((res, user) => {
if (user.age
Hum first hum first 😂
Namaste JS is finally here 🔥🔥🔥
shame on you 🤣🤣🤣🤣🤣🤣🤣
Why?
after watching your videos this concepts got clear . thank you so much sir and i really like that meam part.
I really like how you interact with viewers. ❤️
when will you release a video on the 'This' keyword in JS. We really need to understand how the binding of "this" is different in the arrow function !!
BTW, great work till now!
🙌 I am also waiting for that.
Akshay Bhaiya , Please start a small course or a bootcamp for JS from basic concepts to advanced , this content is gold , we need more of your explanation in various concepts and functional concepts. #JSbyAkshaySaini
Request: Next videos on JAVASCRIPT OOPS concepts please 🙏
thank you
const output = users.reduce(function (acc, curr) {
if(curr.age < 30){
acc.push(curr.firstName);
}
return acc;
}, []);
console.log(output);
I'm too late may be to say this, but i can affirm : it's the best course about explaining map, thank you so much Saini.
I was learning reduce from the video by coding myself and when I tried without assigning an initial value to the acc argument, the first element in the array was assigned to it automatically and the second element was assigned to the curr argument, just sharing an interesting fact, you are a great teacher ❤️❤️
I'm so happy that I started this series.. I feel so confident now Thank you aksay❤️💯🙌
It's the best series to learn js I have ever seen 🤩
Please upload atleast one video per week in this series 🤝
It will be very helpful 🙏
Amazing teaching skills I haven't learnt javascript like never before
map - something from everyone
filter - some from everyone
reduce - onething from everyone
I would love to see object oriented classes in JavaScript and es6 modules as well
I second that, waiting for the same.
I've watched many tutorials on this topic, but this one is truly the best!
ultimate no one can do better than this.
If(curr.age < 30) {
acc.push(curr.firstName);
}
return acc;
/*
Initialise "acc" as an empty array " [ ] " in 2nd paramter of the reduce function
*/
35:50
Sir your contents are soooooooooo useful. It's really helped me to clearly understand map,reduce and filter thoroughly... Lot of love and Thank you ❤️❤️❤️
Akshay, are you kidding me already crossed 100k. Congrats 👏. You are passionate teacher. ❤
Thank you so much brother, it was not possible without your love and support! ❤️
@@akshaymarch7 Home work
const users = [
{ firstName:"akshay", lastName:"bhinge", age:26 },
{ firstName:"donald", lastName:"trump", age:75 },
{ firstName:"elon", lastName:"musk", age:50 },
{ firstName:"deeika", lastName:"padukone", age:29 },
];
const output = users.reduce(function (acc, curr){
if(curr.age < 30){
acc.push(curr.firstName);
}
return acc;
}, [ ] );
console.log(output);
I am in more love with Javascript after watching "Namaste Javascript". I have shared it with all of friends and colleagues to strengthen their knowledge about JS.
Words are not enough to explain the value of this series. Thanks for making this series for everyone with pure love and dedication ❤
No words can express, how grateful I am for your explanation. you killed it! THANK YOU!
const output = users.reduce(function(acc, curr){
if(curr.age < 30){
acc.push(curr.firstName)
}
return acc
}, [])
console.log(output)
Solution for 36:04
const output = users.reduce(function ageReduce(acc,el){
if(el.age
Din ki suruat js ke sath 🔥
You are a true godsend! You’ve got all of the best qualities of a good teacher. Without you, I wouldn’t have made it through.
your way of explanation peeks...like a well-wisher...take a bow
On the contrary, name 'reduce' makes much sense to me since using arr.reduce() we are reducing the whole array to a single value...btw awesome explanation Akshay bhaiya
Hey Akshay,
You are the person who made me fall in love with JS. Thank you ❤️
const usingReduce = names.reduce((acc, curr) => {
if (curr.age < 30) {
acc.push(curr.first)
}
return acc
}, [])
HW :
const op = user.reduce(function(acc,curr){
if(curr.age
Below is another variation of *Example 9 - tricky map()*
const users = [
{ firstName: "Alok", lastName: "Raj", age: 23 },
{ firstName: "Ashish", lastName: "Kumar", age: 29 },
{ firstName: "Ankit", lastName: "Roy", age: 29 },
{ firstName: "Pranav", lastName: "Mukherjee", age: 50 },
];
const fullNameArr = users.map(({firstName, lastName, ...rest}) => {
return {
fullName: firstName + " " + lastName,
...rest,
};
});
console.log(fullNameArr);
In this code, the firstName and lastName properties are destructured from the user object, and the rest of the properties are collected into the rest object using the rest syntax (...rest). Then, a new object is returned with the fullName property and the properties from the rest object. This way, the firstName and lastName properties are not included in the new objects. The new array is then logged to the console. This way, the original users array remains unchanged.
thanks for clearing reduce( )
36:09 - const users = [
{ first: "Rakhi", last: "Barnwal", age: 22 },
{ first: "Elon", last: "Musk", age: 75 },
{ first: "Akshay", last: "Saini", age: 26 },
{ first: "Virat", last: "Kohli", age: 45 },
];
const output = users.reduce(function (acc, curr) {
if (curr.age < 30) {
acc.push(curr.first);
}
return acc;
}, []);
console.log(output);
Please bring a typescript series for nextjs and nest js like this, it will helpfull for all