* chore(i18n,curriculum): update translations * chore: Italian to italian Co-authored-by: Nicholas Carrigan <nhcarrigan@gmail.com>
1.4 KiB
1.4 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
| id | title | challengeType | videoUrl | forumTopicId | dashedName |
|---|---|---|---|---|---|
| 587d7b7e367417b2b2512b23 | Usare la funzione parseInt | 1 | https://scrimba.com/c/cm83LSW | 301183 | use-the-parseint-function |
--description--
La funzione parseInt() analizza una stringa e restituisce un numero intero. Ecco un esempio:
var a = parseInt("007");
La funzione di cui sopra converte la stringa 007 nell'intero 7. Se il primo carattere della stringa non può essere convertito in un numero, restituisce NaN.
--instructions--
Usa parseInt() nella funzione convertToInteger in modo che converta la serie str in un intero e la restituisca.
--hints--
convertToInteger dovrebbe utilizzare la funzione parseInt()
assert(/parseInt/g.test(code));
convertToInteger("56") dovrebbe restituire un numero
assert(typeof convertToInteger('56') === 'number');
convertToInteger("56") dovrebbe restituire 56
assert(convertToInteger('56') === 56);
convertToInteger("77") dovrebbe restituire 77
assert(convertToInteger('77') === 77);
convertToInteger("JamesBond") dovrebbe restituire NaN
assert.isNaN(convertToInteger('JamesBond'));
--seed--
--seed-contents--
function convertToInteger(str) {
}
convertToInteger("56");
--solutions--
function convertToInteger(str) {
return parseInt(str);
}