2021-06-15 03:34:20 +09:00
|
|
|
---
|
|
|
|
id: cf1111c1c11feddfaeb4bdef
|
|
|
|
title: Sottrarre un numero da un altro con JavaScript
|
|
|
|
challengeType: 1
|
|
|
|
videoUrl: 'https://scrimba.com/c/cP3yQtk'
|
|
|
|
forumTopicId: 18314
|
|
|
|
dashedName: subtract-one-number-from-another-with-javascript
|
|
|
|
---
|
|
|
|
|
|
|
|
# --description--
|
|
|
|
|
|
|
|
Possiamo anche sottrarre un numero da un altro.
|
|
|
|
|
|
|
|
JavaScript utilizza il simbolo `-` per la sottrazione.
|
|
|
|
|
|
|
|
**Esempio**
|
|
|
|
|
|
|
|
```js
|
2021-10-27 15:10:57 +00:00
|
|
|
const myVar = 12 - 6;
|
2021-06-15 03:34:20 +09:00
|
|
|
```
|
|
|
|
|
|
|
|
`myVar` avrà il valore `6`.
|
|
|
|
# --instructions--
|
|
|
|
|
|
|
|
Modifica lo `0` in modo che la differenza sia `12`.
|
|
|
|
|
|
|
|
# --hints--
|
|
|
|
|
|
|
|
La variabile `difference` dovrebbe essere uguale a 12.
|
|
|
|
|
|
|
|
```js
|
|
|
|
assert(difference === 12);
|
|
|
|
```
|
|
|
|
|
|
|
|
Devi solo sottrarre un numero da 45.
|
|
|
|
|
|
|
|
```js
|
|
|
|
assert(/difference=45-33;?/.test(__helpers.removeWhiteSpace(code)));
|
|
|
|
```
|
|
|
|
|
|
|
|
# --seed--
|
|
|
|
|
|
|
|
## --after-user-code--
|
|
|
|
|
|
|
|
```js
|
|
|
|
(function(z){return 'difference = '+z;})(difference);
|
|
|
|
```
|
|
|
|
|
|
|
|
## --seed-contents--
|
|
|
|
|
|
|
|
```js
|
2021-10-27 15:10:57 +00:00
|
|
|
const difference = 45 - 0;
|
2021-06-15 03:34:20 +09:00
|
|
|
```
|
|
|
|
|
|
|
|
# --solutions--
|
|
|
|
|
|
|
|
```js
|
2021-10-27 15:10:57 +00:00
|
|
|
const difference = 45 - 33;
|
2021-06-15 03:34:20 +09:00
|
|
|
```
|