en.javascript.info/1-js/4-data-structures/9-array-iteration/1-rewrite-for-map/task.md
2015-03-10 12:36:58 +03:00

21 lines
No EOL
551 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Перепишите цикл через map
[importance 5]
Код ниже получает из массива строк новый массив, содержащий их длины:
```js
//+ run
var arr = ["Есть", "жизнь", "на", "Марсе"];
*!*
var arrLength = [];
for (var i = 0; i < arr.length; i++) {
arrLength[i] = arr[i].length;
}
*/!*
alert( arrLength ); // 4,5,2,5
```
Перепишите выделенный участок: уберите цикл, используйте вместо него метод `map`.