2021-06-15 00:49:18 -07:00
|
|
|
---
|
|
|
|
id: 587d7fb4367417b2b2512bfd
|
2021-07-09 21:23:54 -07:00
|
|
|
title: Aggiungere parole chiave al tuo package.json
|
2021-06-15 00:49:18 -07:00
|
|
|
challengeType: 2
|
|
|
|
forumTopicId: 301526
|
|
|
|
dashedName: add-keywords-to-your-package-json
|
|
|
|
---
|
|
|
|
|
|
|
|
# --description--
|
|
|
|
|
2021-08-25 09:12:11 -07:00
|
|
|
Il campo `keywords` è dove puoi descrivere il tuo progetto usando le parole chiave correlate. Qui un esempio:
|
2021-06-15 00:49:18 -07:00
|
|
|
|
|
|
|
```json
|
|
|
|
"keywords": [ "descriptive", "related", "words" ],
|
|
|
|
```
|
|
|
|
|
2021-07-09 21:23:54 -07:00
|
|
|
Come puoi vedere, questo campo è strutturato come una serie di stringhe tra virgolette doppie.
|
2021-06-15 00:49:18 -07:00
|
|
|
|
|
|
|
# --instructions--
|
|
|
|
|
2021-07-09 21:23:54 -07:00
|
|
|
Aggiungi un array di stringhe adatte al campo `keywords` nel file package.json del tuo progetto.
|
2021-06-15 00:49:18 -07:00
|
|
|
|
2021-07-09 21:23:54 -07:00
|
|
|
Una delle parole chiave dovrebbe essere "freecodecamp".
|
2021-06-15 00:49:18 -07:00
|
|
|
|
|
|
|
# --hints--
|
|
|
|
|
2021-07-09 21:23:54 -07:00
|
|
|
package.json dovrebbe avere una chiave "keywords" valida
|
2021-06-15 00:49:18 -07:00
|
|
|
|
|
|
|
```js
|
|
|
|
(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);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
```
|
|
|
|
|
2021-07-09 21:23:54 -07:00
|
|
|
il campo "keywords" dovrebbe essere un Array
|
2021-06-15 00:49:18 -07:00
|
|
|
|
|
|
|
```js
|
|
|
|
(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);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
```
|
|
|
|
|
2021-07-09 21:23:54 -07:00
|
|
|
"keywords" dovrebbe includere "freecodecamp"
|
2021-06-15 00:49:18 -07:00
|
|
|
|
|
|
|
```js
|
|
|
|
(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);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
```
|
|
|
|
|
|
|
|
# --solutions--
|
|
|
|
|
|
|
|
```js
|
|
|
|
/**
|
|
|
|
Backend challenges don't need solutions,
|
|
|
|
because they would need to be tested against a full working project.
|
|
|
|
Please check our contributing guidelines to learn more.
|
|
|
|
*/
|
|
|
|
```
|