Andrew Zaw 6f4a9ed721 Reorganized instruction text on multiple challenges (#35912)
* Reorganized instruction text on multiple challenges

* Fixed spaces

* Fixed spaces again

* Update curriculum/challenges/english/08-coding-interview-prep/data-structures/add-elements-at-a-specific-index-in-a-linked-list.english.md

Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* Update curriculum/challenges/english/08-coding-interview-prep/data-structures/find-the-minimum-and-maximum-height-of-a-binary-search-tree.english.md

Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* fix: added code tags
2019-06-20 13:16:31 -04:00

2.0 KiB

id, title, challengeType
id title challengeType
587d8254367417b2b2512c70 Create and Add to Sets in ES6 1

Description

Now that you have worked through ES5, you are going to perform something similar in ES6. This will be considerably easier. ES6 contains a built-in data structure Set so many of the operations you wrote by hand are now included for you. Let's take a look: To create a new empty set: var set = new Set(); You can create a set with a value: var set = new Set(1); You can create a set with an array: var set = new Set([1, 2, 3]); Once you have created a set, you can add the values you wish using the add method:
var set = new Set([1, 2, 3]);
set.add([4, 5, 6]);

As a reminder, a set is a data structure that cannot contain duplicate values:

var set = new Set([1, 2, 3, 1, 2, 3]);
// set contains [1, 2, 3] only

Instructions

For this exercise, return a set with the following values: 1, 2, 3, 'Taco', 'Cat', 'Awesome'

Tests

tests:
  - text: 'Your <code>Set</code> should only contain the values <code>1, 2, 3, Taco, Cat, Awesome</code>.'
    testString: 'assert((function(){var test = checkSet(); return (test.size == 6) && test.has(1) && test.has(2) && test.has(3) && test.has("Taco") && test.has("Cat") && test.has("Awesome");})(), "Your <code>Set</code> should only contain the values <code>1, 2, 3, Taco, Cat, Awesome</code>.");'

Challenge Seed

function checkSet() {
  var set = new Set([1, 2, 3, 3, 2, 1, 2, 3, 1]);
  // change code below this line

  // change code above this line
  console.log(Array.from(set));
  return set;
}

checkSet();

Solution

function checkSet(){var set = new Set([1,2,3,'Taco','Cat','Awesome']);
return set;}