Files
freeCodeCamp/curriculum/challenges/italian/02-javascript-algorithms-and-data-structures/basic-javascript/add-new-properties-to-a-javascript-object.md
camperbot b3af21d50f chore(i18n,curriculum): update translations (#42487)
* chore(i18n,curriculum): update translations

* chore: Italian to italian

Co-authored-by: Nicholas Carrigan <nhcarrigan@gmail.com>
2021-06-14 11:34:20 -07:00

1.5 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
56bbb991ad1ed5201cd392d2 Aggiungere nuove proprietà a un oggetto JavaScript 1 https://scrimba.com/c/cQe38UD 301169 add-new-properties-to-a-javascript-object

--description--

Puoi aggiungere nuove proprietà agli oggetti JavaScript esistenti proprio come faresti se volessi modificarli.

Ecco come aggiungere una proprietà bark a ourDog:

ourDog.bark = "bow-wow";

oppure

ourDog["bark"] = "bow-wow";

Ora quando valuteremo ourDog.bark, otterremo il suo abbaiare, bow-wow.

Esempio:

var ourDog = {
  "name": "Camper",
  "legs": 4,
  "tails": 1,
  "friends": ["everything!"]
};

ourDog.bark = "bow-wow";

--instructions--

Aggiungi una proprietà bark a myDog e impostala sul suono di un cane, come "woof". È possibile utilizzare sia la notazione a punti che quella a parentesi.

--hints--

Dovresti aggiungere la proprietà bark a myDog.

assert(myDog.bark !== undefined);

Non dovresti aggiungere bark all'inizializzazione di myDog.

assert(!/bark[^\n]:/.test(code));

--seed--

--after-user-code--

(function(z){return z;})(myDog);

--seed-contents--

var myDog = {
  "name": "Happy Coder",
  "legs": 4,
  "tails": 1,
  "friends": ["freeCodeCamp Campers"]
};


--solutions--

var myDog = {
  "name": "Happy Coder",
  "legs": 4,
  "tails": 1,
  "friends": ["freeCodeCamp Campers"]
};
myDog.bark = "Woof Woof";