Exercises: Objects - Javascript In Depth

preview_player
Показать описание
We go through several practice examples using Objects in Javascript. We combine Objects with Arrays, other Objects and even Functions to create more complex nested Objects to manipulate.

Chapters:
00:00 Introduction
00:23 Warmup Exercise
07:49 Exercise 1
15:50 Exercise 2
30:56 Exercise 3
41:29 BONUS Exercise
49:49 Next Steps

Рекомендации по теме
Комментарии
Автор

I've been learning JavaScript for a while now and I'm so glad I've stumbled upon your channel! You deserve at least 20x more subs.

oloyang
Автор

This is by far the best explanation of anything coding related I've found on YouTube....and I've done a lot of searching. Thank you!

lindajacobsen
Автор

I don't know why but for me 3rd exercise was easier than 2nd one ))
Thank you for such a cool tutorial videos with practice!

TopG-ry
Автор

sir you are my best teacher i really love your videos it improve my logic level, agian THANKS a ALOT

ubaidullah
Автор

Thanks a lot Mr Nader, you helped me a lot to get the hang of the object concept, and understand under the scenes of these stuff. so, i really appreciate your efforts. Thank you so much..

tayibachafrar
Автор

In exercise 2, I wondered first why u said "to change DIRECTLY" in #8... Was it in contrast to #6 where we needed to change the price value of banana through the store...

So I put simply "candy.price = 4.5" 😃 Now I know they needed to be handled equally

ab_semi
Автор

Day 9)
Exercise warmup) Got a little stuck because I kept tryin to do mexico.neighbours and it would return 4, I realised you don't need the mexico.neighbours = part because we aren't trying to assign lol

exercise 1) Strait to the point, easy to follow instructions, adding a new property to an existing object was something I must've forgot but one quick google search and I found a solution!

exercise 2) Much more challenging but super rewarding when we got to implement the knowledge we gained from .filter, and used that to get inside of the objects that were inside of an object and be able to change the object with if statements. Kinda cool felt little like inception in a way lol. I really like the call back to old lessons and what we learned like using a loop to print out only objects in the store, and more questions with loops are much appreciated.
this was how I changed the price of candy from within the store object
console.log(
=> {
if (product === candy) {
return candy.price = 4.99;

}
return false;
})
);
I did the same thing with Banana also but the solution you showed us in the video requires ALOT less typing. omg it makes so much more sense to do it your way then mine haha🤣

exercise 3) Gosh I dont know why I struggled so long with finding
console.log(
houseForSale.offers.reduce((maxOffer, offer) => {
if (maxOffer < offer) {
return offer;
}
return maxOffer;
}, 0)
);
Such a simple solution but I just couldn't think of it. My brain must be turning into mush right now.

exercise BONUS) This is me asking the question before watching the solution but is the built in console working because we basically gave the key a function, and we're calling the function inside the obj with dot notation?

KRAKENBACK..
Автор

Amazing, as always! So much fun to work through your curriculum! :)))

timothyrees
Автор

Cheers, bro!

For exercise 2: 4. Only print out all the product objects in "store", why not just:

console.log(store.products);

Why do we need a for loop?

JoeMilneEnglish
Автор

I am spamming the comments so that this channel gets the views it deserves

nanlunglongtau
Автор

wooow, that console thing really clicked thanks for the video

OXIDE-isgs
Автор

Hello Nader, first of all , thanks a lot with your videos ...just learning a lot from them...

Exercise 2-4
Console.log (Object.entries (store.product))..did not use for loop.what do you think about it?

ranenjims
Автор

The mind is “Ooouuing and Ahhhhing” hahah

nguyennguyen-nmoq
Автор

more on this please, how about typescript or python intermediate to hard level

unknownworld
Автор

sir is there a video on event loop in js?

AbhishekSingh-btuo
Автор

Brother can you give me the answer of bonus excersize no 3. How would i call this log fn inside the obj

comminatinmarkitingdealwit
Автор

I followed your instructions for changing the price of 'banana', but when I print to the console I still see the original price of 1.95.

briaalturi
Автор

This is really confusing me... I think I need to properly understand reduce... what exactly is each reduce parameter? Damn...

const maxPrice = houseForSale.offers.reduce((max, price) => {
if (max < price) {
return price;
}
return max;
}, 0);

console.log(maxPrice);
// 315000

JoeMilneEnglish
Автор

Hi
in the exercise, when it came to the reduce part
, if we solve it like this, what's the difference?

const maxPrice = houseForSale.offers.reduce((min, current) => {
if (min > current) {
return min;
}
return current;
}, 0);

it gives me the max value, but i feel like its wrong?

ilijajovanov
Автор

Just wondering on exercise 2, step 4, I just used console.log(store.products);
That printed out the same way as the for statement you utilized, is the way I did it wrong?
Also, on exercise 3, I just wrote the code:

const offerPrice = houseForSale.offers.reduce((result, offer) => {
return Math.max(offer, result)
}, 0)


I started with an if statement, but kept getting undefined, because I forgot to the the second 'else' portion of the if statement. So I just used Math.max

Is this an acceptable way? The result was the same.

vagabond