Files
freeCodeCamp/curriculum/challenges/espanol/02-javascript-algorithms-and-data-structures/basic-javascript/finding-a-remainder-in-javascript.md
2023-02-20 20:31:01 +01:00

1.4 KiB

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

--description--

El operador de resto % entrega el resto de la división entre dos números.

Ejemplo

5 % 2 = 1
5 / 2 = 2 remainder 1
2 * 2 = 4
5 - 4 = 1

Usage
In mathematics, a number can be checked to be even or odd by checking the remainder of the division of the number by 2. Even numbers have a remainder of 0, while odd numbers a remainder of 1.

17 % 2 = 1
48 % 2 = 0

Nota: El operador de resto es a veces incorrectamente referido como el operador módulo. Es muy similar al módulo, pero no funciona adecuadamente con números negativos.

--instructions--

Establece remainder igual al resto de 11 dividido entre 3 usando el operador de resto (%).

--hints--

La variable remainder debe inicializarse

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

El valor de remainder debe ser 2

assert(remainder === 2);

Debes usar el operador %

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

--seed--

--after-user-code--

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

--seed-contents--

const remainder = 0;

--solutions--

const remainder = 11 % 3;