2.8 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
587d824b367417b2b2512c4a | Usare il doppio uguale per affermare l'uguaglianza | 2 | 301609 | use-the-double-equals-to-assert-equality |
--description--
Come promemoria, questo progetto verrà costruito a partire dalla seguente bozza su Replit, o clonato da GitHub.
equal()
confronta oggetti usando ==
.
--instructions--
All'interno di tests/1_unit-tests.js
, sotto il test etichettato con #5
, nella suite Equality
, cambia ogni asserzione assert
in assert.equal
o assert.notEqual
per far passare il test (dovrebbe risultare true
). Non alterare gli argomenti passati alle asserzioni.
--hints--
Tutti i test dovrebbero essere superati.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=4').then(
(data) => {
assert.equal(data.state, 'passed');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
Dovresti scegliere il metodo corretto per la prima asserzione - equal
oppure notEqual
.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=4').then(
(data) => {
assert.equal(
data.assertions[0].method,
'equal',
'Numbers are coerced into strings with == '
);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
Dovresti scegliere il metodo corretto per la seconda asserzione - equal
oppure notEqual
.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=4').then(
(data) => {
assert.equal(
data.assertions[1].method,
'notEqual',
' == compares object references'
);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
Dovresti scegliere il metodo corretto per la terza asserzione - equal
oppure notEqual
.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=4').then(
(data) => {
assert.equal(
data.assertions[2].method,
'equal',
"6 * '2' is 12 ! It should be equal to '12'"
);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
Dovresti scegliere il metodo corretto per la quarta asserzione - equal
oppure notEqual
.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=4').then(
(data) => {
assert.equal(data.assertions[3].method, 'notEqual', "6 + '2' is '62'...");
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
--solutions--
/**
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.
*/