translating
This commit is contained in:
parent
2b874a73be
commit
928cd2731b
165 changed files with 2046 additions and 2967 deletions
|
@ -1,9 +1,11 @@
|
|||
Для вывода нужен случайный номер от `0` до `arr.length-1` включительно.
|
||||
We need to generate a random integer value from `0` to `arr.length-1`, and then take the element with that index.
|
||||
|
||||
Here we go:
|
||||
|
||||
```js run
|
||||
var arr = ["Яблоко", "Апельсин", "Груша", "Лимон"];
|
||||
let arr = ["Apple", "Orange", "Pear", "Lemon"];
|
||||
|
||||
var rand = Math.floor(Math.random() * arr.length);
|
||||
let rand = Math.floor(Math.random() * arr.length);
|
||||
|
||||
alert( arr[rand] );
|
||||
```
|
||||
|
|
|
@ -2,17 +2,10 @@ importance: 3
|
|||
|
||||
---
|
||||
|
||||
# Получить случайное значение из массива
|
||||
# A random array value
|
||||
|
||||
Напишите код для вывода `alert` случайного значения из массива:
|
||||
Write the code to `alert` a random value from the array:
|
||||
|
||||
```js
|
||||
var arr = ["Яблоко", "Апельсин", "Груша", "Лимон"];
|
||||
let arr = ["Apple", "Orange", "Pear", "Lemon"];
|
||||
```
|
||||
|
||||
P.S. Код для генерации случайного целого от `min` to `max` включительно:
|
||||
|
||||
```js
|
||||
var rand = min + Math.floor(Math.random() * (max + 1 - min));
|
||||
```
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue