2021-02-06 04:42:36 +00:00
|
|
|
---
|
|
|
|
id: cf1111c1c11feddfaeb4bdef
|
2021-03-15 20:01:16 +00:00
|
|
|
title: Resta un número de otro con JavaScript
|
2021-02-06 04:42:36 +00:00
|
|
|
challengeType: 1
|
|
|
|
videoUrl: 'https://scrimba.com/c/cP3yQtk'
|
|
|
|
forumTopicId: 18314
|
|
|
|
dashedName: subtract-one-number-from-another-with-javascript
|
|
|
|
---
|
|
|
|
|
|
|
|
# --description--
|
|
|
|
|
2021-03-15 20:01:16 +00:00
|
|
|
También podemos restar un número de otro.
|
2021-02-06 04:42:36 +00:00
|
|
|
|
2021-03-15 20:01:16 +00:00
|
|
|
JavaScript utiliza el símbolo `-` para restar.
|
2021-02-06 04:42:36 +00:00
|
|
|
|
2021-03-15 20:01:16 +00:00
|
|
|
**Ejemplo**
|
2021-02-06 04:42:36 +00:00
|
|
|
|
|
|
|
```js
|
2021-03-15 20:01:16 +00:00
|
|
|
myVar = 12 - 6;
|
2021-02-06 04:42:36 +00:00
|
|
|
```
|
|
|
|
|
2021-03-15 20:01:16 +00:00
|
|
|
`myVar` tendrá el valor `6`.
|
2021-02-06 04:42:36 +00:00
|
|
|
# --instructions--
|
|
|
|
|
2021-03-15 20:01:16 +00:00
|
|
|
Cambia el `0` para que la diferencia sea `12`.
|
2021-02-06 04:42:36 +00:00
|
|
|
|
|
|
|
# --hints--
|
|
|
|
|
2021-03-15 20:01:16 +00:00
|
|
|
La variable `difference` debe ser igual a 12.
|
2021-02-06 04:42:36 +00:00
|
|
|
|
|
|
|
```js
|
|
|
|
assert(difference === 12);
|
|
|
|
```
|
|
|
|
|
2021-03-15 20:01:16 +00:00
|
|
|
Sólo debes restar un número de 45.
|
2021-02-06 04:42:36 +00:00
|
|
|
|
|
|
|
```js
|
|
|
|
assert(/difference=45-33;?/.test(__helpers.removeWhiteSpace(code)));
|
|
|
|
```
|
|
|
|
|
|
|
|
# --seed--
|
|
|
|
|
|
|
|
## --after-user-code--
|
|
|
|
|
|
|
|
```js
|
|
|
|
(function(z){return 'difference = '+z;})(difference);
|
|
|
|
```
|
|
|
|
|
|
|
|
## --seed-contents--
|
|
|
|
|
|
|
|
```js
|
|
|
|
var difference = 45 - 0;
|
|
|
|
```
|
|
|
|
|
|
|
|
# --solutions--
|
|
|
|
|
|
|
|
```js
|
|
|
|
var difference = 45 - 33;
|
|
|
|
```
|