Randell Dawson e9212c61d2 fix(curriculum): Remove unnecessary assert message argument from English challenges JavaScript Algorithms and Data Structures - 01 (#36401)
* fix: rm assert msg basic-javascript

* fix: removed more assert msg args

* fix: fixed verbiage

Co-Authored-By: Parth Parth <34807532+thecodingaviator@users.noreply.github.com>
2019-07-13 08:07:53 +01:00

1.6 KiB

id, title, challengeType, videoUrl
id title challengeType videoUrl
56bbb991ad1ed5201cd392d3 Delete Properties from a JavaScript Object 1 https://scrimba.com/c/cDqKdTv

Description

We can also delete properties from objects like this: delete ourDog.bark;

Instructions

Delete the "tails" property from myDog. You may use either dot or bracket notation.

Tests

tests:
  - text: Delete the property <code>"tails"</code> from <code>myDog</code>.
    testString: assert(typeof myDog === "object" && myDog.tails === undefined);
  - text: Do not modify the <code>myDog</code> setup
    testString: 'assert(code.match(/"tails": 1/g).length > 1);'

Challenge Seed

// Example
var ourDog = {
  "name": "Camper",
  "legs": 4,
  "tails": 1,
  "friends": ["everything!"],
  "bark": "bow-wow"
};

delete ourDog.bark;

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

// Only change code below this line.


After Test

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

Solution

var ourDog = {
  "name": "Camper",
  "legs": 4,
  "tails": 1,
  "friends": ["everything!"],
  "bark": "bow-wow"
};
var myDog = {
  "name": "Happy Coder",
  "legs": 4,
  "tails": 1,
  "friends": ["freeCodeCamp Campers"],
  "bark": "woof"
};
delete myDog.tails;