freeCodeCamp/curriculum/challenges/chinese/05-apis-and-microservices/managing-packages-with-npm/add-keywords-to-your-packag...

1.8 KiB

id title localeTitle challengeType
587d7fb4367417b2b2512bfd Add Keywords to Your package.json 将关键字添加到package.json 2

Description

keywords-field是您可以使用相关关键字描述项目的地方。 0示例 "keywords": [ "descriptive", "related", "words" ], 0如您所见,此字段的结构为双引号字符串数组。 0说明0将一组合适的字符串添加到Glitch项目的package.json中的keywords-field。 0其中一个关键字应该是freecodecamp。

Instructions

Tests

tests:
  - text: package.json应该有一个有效的“关键字”键
    testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert(packJson.keywords, ''"keywords" is missing''); }, xhr => { throw new Error(xhr.responseText); })'
  - text: '“keywords”字段应为Array'
    testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.isArray(packJson.keywords, ''"keywords" is not an array''); }, xhr => { throw new Error(xhr.responseText); })'
  - text: '“关键字”应包含“freecodecamp”'
    testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data);     assert.include(packJson.keywords, ''freecodecamp'', ''"keywords" does not include "freecodecamp"''); },  xhr => { throw new Error(xhr.responseText); })'

Challenge Seed

Solution

// solution required