Is this a bug or am I missing something?

Is this a bug or am I missing something?
0

#1

I’m not sure if this is a bug or FCC does this for a reason. I just completed the “Record Collection” problem in the Advanced Algorithm section for Front End and noticed that my results changed if I gave the object calls a variable name and called them using the variable name (for example: creating a “var item = collection[id][prop]” and then just using “item” for the rest of the code rather than using “collection[id][prop]” every time). I feel like I should be using DRY coding techniques and using “collection[id][prop]” every time rather than a shorter variable name just doesn’t seem very DRY to me. My code works either way in the dev console; just not in FCC’s challenge page console. I’m curious if there’s a reason for this. I’ve posted a before and after for my solution to give a bit more context if I’m not explaining this well enough. Thanks.


#2

var newProp = collection[id][prop]; sets newProp to the value contained in collection[id][prop]. Trying to delete it just deletes that variable - not the property collection[id][prop], etc.


#3

Ah, yeah, actually with a bit more playing around, I realized what the problem was. In addition to deleting the variable, I was also reassigning a variable in parts. Thanks!