mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-25 05:02:17 -04:00
chore(i18n,learn): processed translations (#50168)
This commit is contained in:
@@ -9,25 +9,25 @@ dashedName: generate-random-whole-numbers-with-javascript
|
||||
|
||||
# --description--
|
||||
|
||||
You can generate random decimal numbers with `Math.random()`, but sometimes you need to generate random whole numbers. The following process will give you a random whole number less than `20`:
|
||||
Puoi generare numeri decimali casuali con `Math.random()`, ma a volte devi generare numeri interi casuali. Il seguente processo ti darà un numero intero casuale inferiore a `20`:
|
||||
|
||||
1. Use `Math.random()` to generate a random decimal number.
|
||||
2. Multiply that random decimal number by `20`.
|
||||
3. Use `Math.floor()` to round this number down to its nearest whole number.
|
||||
1. Utilizza `Math.random()` per generare un numero decimale casuale.
|
||||
2. Moltiplica quel numero decimale casuale per `20`.
|
||||
3. Usa `Math.floor()` per arrotondare il numero per difetto al numero intero più vicino.
|
||||
|
||||
Remember that `Math.random()` can never quite return a `1`, so it's impossible to actually get `20` since you are rounding down with `Math.floor()`. This process will give you a random whole number in the range from `0` to `19`.
|
||||
Ricorda che `Math.random()` non può mai restituire `1`, quindi non è possibile ottenere `20` dato che stai arrotondando con `Math.floor()`. Questo procedimento ti darà un numero intero casuale nell'intervallo da `0` a `19`.
|
||||
|
||||
Putting everything together, this is what your code looks like:
|
||||
Mettendo tutto insieme, questo è il codice:
|
||||
|
||||
```js
|
||||
Math.floor(Math.random() * 20);
|
||||
```
|
||||
|
||||
You are calling `Math.random()`, multiplying the result by 20, then passing the value to `Math.floor()` to round the value down to the nearest whole number.
|
||||
Stai chiamando `Math.random()`, moltiplicando il risultato per 20, quindi passando il valore a `Math.floor()` per arrotondare il valore per difetto al numero intero più vicino.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Use this technique to generate and return a random whole number in the range from `0` to `9`.
|
||||
Usa questa tecnica per generare e restituire un numero intero casuale nell'intervallo tra `0` e `9`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -49,7 +49,7 @@ Dovresti usare `Math.random` per generare un numero casuale.
|
||||
assert(code.match(/Math.random/g).length >= 1);
|
||||
```
|
||||
|
||||
You should have multiplied the result of `Math.random` by 10 to make it a number in the range from zero to nine.
|
||||
Dovresti moltiplicare il risultato di `Math.random` per 10 per ottenere un numero nell'intervallo tra zero e nove.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
||||
@@ -9,11 +9,11 @@ dashedName: generate-random-whole-numbers-within-a-range
|
||||
|
||||
# --description--
|
||||
|
||||
You can generate a random whole number in the range from zero to a given number. You can also pick a different lower number for this range.
|
||||
Puoi generare un numero intero casuale nell'intervallo da zero a un dato numero. Puoi anche scegliere un numero inferiore diverso per questo intervallo.
|
||||
|
||||
You'll call your minimum number `min` and your maximum number `max`.
|
||||
Chiamerai il numero minimo `min` e il numero massimo `max`.
|
||||
|
||||
This formula gives a random whole number in the range from `min` to `max`. Prenditi un momento per leggerlo e prova a capire cosa sta facendo questo codice:
|
||||
Questa formula dà un numero intero casuale nell'intervallo da `min` a `max`. Prenditi un momento per leggerlo e prova a capire cosa sta facendo questo codice:
|
||||
|
||||
```js
|
||||
Math.floor(Math.random() * (max - min + 1)) + min
|
||||
@@ -21,7 +21,7 @@ Math.floor(Math.random() * (max - min + 1)) + min
|
||||
|
||||
# --instructions--
|
||||
|
||||
Create a function called `randomRange` that takes a range `myMin` and `myMax` and returns a random whole number that's greater than or equal to `myMin` and less than or equal to `myMax`.
|
||||
Crea una funzione `randomRange` che prende un intervallo `myMin` e `myMax` e restituisce un numero intero casuale maggiore o uguale di `myMin` e minore o uguale di `myMax`.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
Reference in New Issue
Block a user