There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
When i tried create .invert() object with two ways :
invert (object) {
let invertedObject = {};
for (let key in object) {
invertedObject[object[key]] = key
};
return invertedObject;
}
This works fine but :
invert (object) {
let invertedObject = {};
for (let key in object) { invertedObject.object[key] = key
};
return invertedObject;
}
delete objectName[‘Property Name’];
delete objectName.propName;
this is the example they give to delete. Does it not work because it has space in the key? "Secret Mission??? I to am trying to figure it out?
/*
OBJECT: lambo
KEY: garageLocation, "door type", color, "still available"
VALUE: "bay area", "suicide door", "fancy shmancy", "yes"
if the KEY has "two words" or "special symbol", they must be included in quotation marks
*/
let lambo = {
garageLocation: "bay area",
"door type": "suicide door",
color: "fancy shmancy",
"still available": "yes"
}
console.log(lambo);
//ACCESS TO KEYS
console.log("one word KEY color (dot): "+lambo.color);
console.log("two words KEY door type [square brackets]:"+lambo["door type"]);
//KEY CHANGE
lambo["door type"] = "regular"; //assigning new property
console.log("KEY'door type' changed ")
console.log(lambo);
//Deleting property from an object with delete operator
delete lambo.color;
delete lambo["still available"];
//Priting updated object lambo, without two last keys
console.log(lambo);
Has anyone encountered a problem going pass Step 1? I couldn’t move on to Step 2 even after my code was correct. Maybe I’m not seeing it correctly but is the code below for step 1 correct?
When I try a delete operate with a string property name, do I have to use the bracket notation [ ]? When I tried to run the string using delete spaceship.‘Secret Mission’; I get syntax error.
However, when I utilize delete spaceship[‘Secret Mission’]; there is no error ( and this is also the correct solution).
Not a copy, the same array, only mutated. a still points to the same object.
That is the basic difference between the two terms mentioned. In the first example, by re-assigning a a new value, a now points to a different object than before. That’s when the object was a number. When we made a into an array changing the array values did not change what a references. Making sense?