Modify an Array Stored in an Object - Basic Data Structures - Free Code Camp

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

after going through some of these videos I go through the comment to see if I am the only one experiencing this same challenge. voila, there is hope. I am not alone. Thanks Ian.

successimamun
Автор

great video as always! a question: how is it that you hover over the FCC editor and it displays information of data types etc? Mine doesn't do that and it looks handy as all get out! :D

shannonstumpf
Автор

Sometimes I just don’t know how to start it or anything really stressful cause putting so many hours into this everyday but can’t get head around some stuff but thanks for vid

paulfanning
Автор

Hi mate, ive been self learning web dev and now been follwing the JS curriculum on freecodecamp, stumbled upon your video here. Anyway, i wanted to say something, like i mentioned, although ive now understood the basics of JS (currently in Basic Data Structures) im having difficulty to complete these exercises, its like everything ive just learnt is wiped from my memory or its all in there and i dont know how to apply them or use them to write a function or an if statement or loop, anything for that matter. What do you think is my problem? Does this mean that im not meant to do this? idk what else to think lol please advice, it would mean alot thanks

kieran
Автор

The exercise in this video, i just kept staring at it and then reading it over and over and i couldnt solve it on my own. I had to watch your video to understand how to go about it. sucks really, hope i can overcome this problem of mine at some point

kieran
Автор

I managed to get this to pass using :

return user.data.friends;


I'm wondering what is the correct way and why? i.e user or userObj in the solution?


Thanks again

glenroyterence
Автор

I tried solving this challenge using bracket notation, yet kept getting "data is not defined". I wanted bracket notation to work, and after watching your video, I edited my code to use dot notation, which then worked. Why does bracket notation not work with this challenge?
Also, thanks for all your videos!

JonathanWrightZA
Автор

Thanks mate, I was struggling with it a little! You should have read freeCodeCamp.org comment - Nuclear launch detected. Do you remember Starcraft? hehehe.

astratow
Автор

let friendlist = userObj["data"].friends
friendlist.push(friend)
return friendlist

this passes but always good to do extra research and see what other solutions there are

shaynearcher
Автор

here is what I used to pass this challenge

// Only change code below this line
let circle = user.data.friends;
if === false) {
circle.push(friend);
}
return circle;
// Only change code above this line

I defined all the friends that ken has to his 'circle' and then used the hasOwnProperty with an if statement to check is pete is a friend already then if not then I used the push method to add him to the array hope this helps

kevincarter
Автор

Thank you Mr. Ian I am ready to move on to the next section of JS.
function addFriend(userObj, friend) {


return userObj.data.friends;

}

console.log(addFriend(user, 'Pete'));
console.log(user);

zken
join shbcf.ru