Files
freeCodeCamp/curriculum/challenges/italian/02-javascript-algorithms-and-data-structures/basic-javascript/finding-a-remainder-in-javascript.md
camperbot b3af21d50f chore(i18n,curriculum): update translations (#42487)
* chore(i18n,curriculum): update translations

* chore: Italian to italian

Co-authored-by: Nicholas Carrigan <nhcarrigan@gmail.com>
2021-06-14 11:34:20 -07:00

1.5 KiB
Raw Blame History

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
56533eb9ac21ba0edf2244ae Trovare un resto in JavaScript 1 https://scrimba.com/c/cWP24Ub 18184 finding-a-remainder-in-javascript

--description--

Loperatore resto % fornisce il resto della divisione di due numeri.

Esempio

5 % 2 = 1 perché
Math.floor(5 / 2) = 2 (Quoziente)
2 * 2 = 4
5 - 4 = 1 (Resto)

Uso
In matematica si può verificare se un numero è pari o dispari controllando il resto della divisione del numero per 2.

17 % 2 = 1 (17 è dispari)
48 % 2 = 0 (48 è pari)

Nota: L'operatore resto è a volte erroneamente indicato come l'operatore del modulo. Esso è molto simile al modulo, ma non funziona correttamente con numeri negativi.

--instructions--

Imposta remainder pari al resto di 11 diviso per 3 utilizzando l'operatore resto (%).

--hints--

La variabile remainder dovrebbe essere inizializzata

assert(/var\s+?remainder/.test(code));

Il valore di remainder dovrebbe essere 2

assert(remainder === 2);

Dovresti utilizzare l'operatore %

assert(/\s+?remainder\s*?=\s*?.*%.*;?/.test(code));

--seed--

--after-user-code--

(function(y){return 'remainder = '+y;})(remainder);

--seed-contents--

// Only change code below this line

var remainder;

--solutions--

var remainder =  11 % 3;