Using map() to return all names in capital 🔥 #javascript #javascriptinterview

preview_player
Показать описание
Javascript Interview Question on map will be discussed in this video. This is very important for frontend interviews.
Рекомендации по теме
Комментарии
Автор

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.

anantsharma
Автор

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.

SatyakiBhargava
Автор

Very good coding questions. Please keep posting more such shorts.

ankushmalik
Автор

also arr.reduce((acc, curr)=>{
return [...acc, curr.name.toUpperCase()]
}, []) will be very efficient

ikoiko
Автор

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). 😅😅😅😅

kaushikitagib
Автор

Bro map also does same for loop in its inner method and returns new array, 😅 basically it's one and the same

darshanhegde
Автор

It wasn't a messy code it was straight forward 😂

SpideyGuy
Автор

ok now check the performance between these 3 looping mechanisms and choose which is better

smachohalla
Автор

Isn't this approach taking extra space, (for map approach)

VikashKumar-trcq
Автор

const capitalStudentsNames = students.map(({name}) => name.toUpperCase());

דניאלאביב-ות
Автор

You could have destructed the name to reduce the code further

MightyIndians
Автор

But for performance. For each is better.

appwala
Автор

it will be very easy.. if you have minimum common science👀😐

personalatick
Автор

You cant use foreach, since foreach cant return any values but it still able to convert to capitalize

ardhiyanah
Автор

Loop performance is far better for large data sets

tafaxtra
Автор

you could've also used the Some function

astitva
Автор

//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){

}
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){

}
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},
];

console.log(student3);

abisekhdey
Автор

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

omrout
Автор

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

Lucifer-xtun
Автор

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

iamworstgamer
visit shbcf.ru