Back to Freecodecamp

Add Keywords to Your package.json

curriculum/challenges/english/blocks/managing-packages-with-npm/587d7fb4367417b2b2512bfd.md

latest1.4 KB
Original Source

--description--

The keywords field is where you can describe your project using related keywords. Here's an example:

json
"keywords": [ "descriptive", "related", "words" ],

As you can see, this field is structured as an array of double-quoted strings.

--instructions--

Add an array of suitable strings to the keywords field in the package.json file of your project.

One of the keywords should be "freecodecamp".

--hints--

package.json should have a valid "keywords" key

js
fetch(code + '/_api/package.json')
  .then(response => response.json())
  .then(
    data => {
      assert.exists(data.keywords, '"keywords" is missing');
    },
    error => {
      throw new Error(error.message || error.responseText);
    }
  );

"keywords" field should be an Array

js
fetch(code + '/_api/package.json')
  .then(response => response.json())
  .then(
    data => {
      assert.isArray(data.keywords, '"keywords" is not an array');
    },
    error => {
      throw new Error(error.message || error.responseText);
    }
  );

"keywords" should include "freecodecamp"

js
fetch(code + '/_api/package.json')
  .then(response => response.json())
  .then(
    data => {
      assert.include(
        data.keywords,
        'freecodecamp',
        '"keywords" does not include "freecodecamp"'
      );
    },
    error => {
      throw new Error(error.message || error.responseText);
    }
  );