Problem with adding new properies to objects in js

Tell us what’s happening:

hey, I can’t figure out what’s wrong with it . Can anyone please help?

Your code so far

// Setup
var myDog = {
 "name": "Happy Coder",
 "legs": 4,
 "tails": 1,
 "friends": ["freeCodeCamp Campers"]
myDog['bark'] = "woof";

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36.

Challenge: Add New Properties to a JavaScript Object

Link to the challenge:

You might want to try inconito mode.
I ran thiis code and it passes for me

1 Like

it worked! thank you so much.

Just to add, given it worked, then assume that something was cached by the browser from a previous attempt (eg something didn’t work last time out, and the tests are running against that). Just if you get this in future, going into incognito mode fixes it because it won’t store data from previous sessions – it’s not a total fix because it’s also not going to store your local progress (it’ll natch work though)


great !! i’ll try it next time.

How come FCC doesnt just run the code in an IIFE? That would solve all the cached variable problems.

I don’t know. Also note many challenges were wrapped in IIFEEs in the code users saw (mainly for other reasons), and it is super duper confusing for people learning. I’ve also never investigated why this happens for some users – it only happens for some users, so it could also be something else. Clearing cache/equivalent works totally fine 99% of the time and is super easy, so that just gets recommended.

For sure it would be confusing to see if they were just starting out; but, just like how they use ‘use strict’ behind the scene, why not use IIFE behind scene.

Spending hours on trying to fix something that isn’t broke is very frustrating as I’m sure you know.

This is not the correct place to have this discussion. It’s related to this, which is the most relevant open issue (keep reading down, solutions are currently stored while a user is doing a specific challenge, then if they are logged in they are wiped after it is completed (this is supposed to be universal behaviour, not saving due to edge case issues with local storage). If they aren’t logged the solution isn’t wiped (this is the issue raised).

The solutions being stored while a user is on a specific challenge is what seems to be causing this, but I personally am not familiar with the codebase, and I don’t have time to build a local version and figure out how to replicate.

If you think you know a fix for the issue, then please talk to the maintainers via GitHub.