👉Watch full video here - ruclips.net/video/dGq0gi0wv64/видео.html ➡️ Book an Interview Preparation call with me ( 20% OFF for limited time ) - topmate.io/roadsidecoder
Its called lambda functions or annonymous function. And code is never messy because of more number of lines. That lambda you wrote is hard to bring in unit test coverage.
actually Space complexity of map is o(n) and for loop people claim it's o(1). but since, we use array for result the auxiliary space still be o(n). 😅😅😅😅
//9a. Convert The names into Upper Case using for of loop let student1=[ {Student: "Abisekh",roll:1}, {Student: "Pallabi",roll:2}, {Student: "Subham",roll:3}, {Student: "Raktim",roll:4}, ]; for(let i of student1){ i.Student=i.Student.toUpperCase(); } console.log(student1); //9b. Convert The names into Upper Case using for in loop let student2=[ {Student: "Abisekh",roll:1}, {Student: "Pallabi",roll:2}, {Student: "Subham",roll:3}, {Student: "Raktim",roll:4}, ]; for(let i in student2){ student2[i].Student=student2[i].Student.toUpperCase(); } console.log(student2); //9c. Convert The names into Upper Case using forEach loop let student3=[ {Student: "Abisekh",roll:1}, {Student: "Pallabi",roll:2}, {Student: "Subham",roll:3}, {Student: "Raktim",roll:4}, ]; student3.forEach((val)=>val.Student=val.Student.toUpperCase()) console.log(student3);
Please make a full length video with questions like these on objects bro there is no video on youtube i searched a lot. So it help a lot mutually please reply if you read and consider my request
Bhai i am commerce background student .Last 2.5 year i learned and make project on MERN stack but some time in my mind create negatives thought's can i make good decision . Make me sure it
@@RoadsideCoderobviously, the time complexity is the same but I've heard using map instead of a for loop is a little bit slower; so over a large array, it adds up lemme measure and update
there can be multiple approach to a stupid question? no, its just getting keys from each object and upper case, every approach is same. choose one which is more idiomatic
👉Watch full video here - ruclips.net/video/dGq0gi0wv64/видео.html
➡️ Book an Interview Preparation call with me ( 20% OFF for limited time ) - topmate.io/roadsidecoder
It is not always the one liner or two liner code but how readable your code is.
Here it is fine because it was straight forward.
You have experience bro 🎉
If you can't read code, then you can leave coding
You don't have any idea , how much pressure we have to bear on those deadlines.
@@randomviralshorts1501 So You don't know how to write a maintainable, readable and good code. Okay. 👍🏻👍🏻
Very good coding questions. Please keep posting more such shorts.
Its called lambda functions or annonymous function. And code is never messy because of more number of lines. That lambda you wrote is hard to bring in unit test coverage.
Why it is difficult
@@gururaviteja Every high level of abstraction is hard to understand by machine
True first one is not messy it's readable and easily understandable
CSS:
text-transform: uppercase;
also arr.reduce((acc,curr)=>{
return [...acc,curr.name.toUpperCase()]
},[]) will be very efficient
actually Space complexity of map is o(n) and for loop people claim it's o(1). but since, we use array for result the auxiliary space still be o(n). 😅😅😅😅
Bro map also does same for loop in its inner method and returns new array, 😅 basically it's one and the same
Isn't this approach taking extra space, (for map approach)
Yup it creates another nested array to store the new result, map method doesn't modifies the original array it creates a new copy of it.
Nice👍🏻
You could have destructed the name to reduce the code further
you could've also used the Some function
But for performance. For each is better.
source?
Have used reduce ?
const capitalStudentsNames = students.map(({name}) => name.toUpperCase());
It was the easiest question
You cant use foreach, since foreach cant return any values but it still able to convert to capitalize
It wasn't a messy code it was straight forward 😂
ok now check the performance between these 3 looping mechanisms and choose which is better
How to check performance
Great one ❤
Thanks 🔥
Touppercase ()
What about performance if array has millions of records?
It will work, map is just a loop
@@RoadsideCoder I think it'll not provide better performance over for loop.
Behind the scenes, it uses for loop only
it will be very easy.. if you have minimum common science👀😐
//9a. Convert The names into Upper Case using for of loop
let student1=[
{Student: "Abisekh",roll:1},
{Student: "Pallabi",roll:2},
{Student: "Subham",roll:3},
{Student: "Raktim",roll:4},
];
for(let i of student1){
i.Student=i.Student.toUpperCase();
}
console.log(student1);
//9b. Convert The names into Upper Case using for in loop
let student2=[
{Student: "Abisekh",roll:1},
{Student: "Pallabi",roll:2},
{Student: "Subham",roll:3},
{Student: "Raktim",roll:4},
];
for(let i in student2){
student2[i].Student=student2[i].Student.toUpperCase();
}
console.log(student2);
//9c. Convert The names into Upper Case using forEach loop
let student3=[
{Student: "Abisekh",roll:1},
{Student: "Pallabi",roll:2},
{Student: "Subham",roll:3},
{Student: "Raktim",roll:4},
];
student3.forEach((val)=>val.Student=val.Student.toUpperCase())
console.log(student3);
Please make a full length video with questions like these on objects bro there is no video on youtube i searched a lot. So it help a lot mutually please reply if you read and consider my request
Already Made - ruclips.net/video/dGq0gi0wv64/видео.html
@@RoadsideCoder sir im asking to create a full length video on different types of object coding questions as like u did for arrays in DSA playlist
That is also made - ruclips.net/video/XnFIX3c7xoI/видео.html
Bhai i am commerce background student .Last 2.5 year i learned and make project on MERN stack but some time in my mind create negatives thought's can i make good decision . Make me sure it
give it some time, start with basics and try creating projects on your own without watching tutorials
@@RoadsideCoder Commerce student can become webdevloper
Yes
@@RoadsideCoder tq so much. Your word felling better
Loop performance is far better for large data sets
how? Give me time complexity of both
Right @tafaxtra
@@RoadsideCoderif we do run any script for longer time then for loop has much more control than map or foreach.
@@RoadsideCoderobviously, the time complexity is the same
but I've heard using map instead of a for loop is a little bit slower; so over a large array, it adds up
lemme measure and update
Easiest interview question.
there can be multiple approach to a stupid question? no, its just getting keys from each object and upper case, every approach is same. choose one which is more idiomatic
He is making up questions for the 1 concept he learned. I think his show off skills are better than his coding skills
always use for loop bro
map uses for loop behind the scenes
It production it doesn't works like that, when you have thousands of lines of code
It will work of its 10^8 also
Idk why simple for loop look messy for me entire js look messy no hates on js but it syntax is weird compare to other languages i have seen
For loop was not messy
You didn’t mention mighty reduce method
I have, in the full video
👍
but it is supposed to be slow actually
Me: There can be multiple approach for this problem
Interviewer: Mention all aproaches
Me: Mada.............
Interviewer asks to convert into uppercase?
yes, but he wont tell u the toUppercase function
@@RoadsideCoder but I heard that you're allowed to use google or any other source
not for such obvious things
What the interviewer asked and what are you doing bro?
What did i do?
Is it to convert them to uppercase or return names which are in capital letters?
How about using groupby on the object and then using object.keys to get the name.
Interviewer gaved is ..
Map😊
What is stu
just a variable name, can be anything
What kind of interviewer asks this stuff 😂
from junior devs
For which junior role?
I don't think you write 3 lines or 1 makes any difference if it is readable. It matters if the complexity also changes.
Bhai Mera naam 🙌 vrna Rahul rohit hi dekte hai 😂
Interviewer vi lagta h hr hi hogi jisko yeh question net pe mil gaya hoga aur wahi chipka di😂😂😂😂
Ye esa question college me b nhi puchhte interview toh bht door hai 😂
to fir kya puchte hai?
@@RoadsideCoder Rocket Science 😂
Str in arrow function 😂
Bro not even kidding my name us Piyush and my role number is 31
hahah, great
Sorry no javascript allowed
LinkedIn id
www.linkedin.com/in/piyush-eon/
Noob