Loop Expressions

map() method is a good way of creating a new array after looping through an existing array, but it would be convenient to have loop expressions when you are dealing with more than one array or no arrays at all.

Range of numbers

const res = for (let i = 0; i < 10; ++i) do yield i;
consolt.log(res); // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Mapping

const myArr = ["foo", "bar"];
const res = for (const item of myArr) do yield item.toUpperCase();
consolt.log(res); // ["FOO", "BAR"]

With a block

const myArr = ["foo", "bar"];
const res = for (const item of myArr) do {
    const upper = item.toUpperCase();
    yield upper;
}
consolt.log(res) // ["FOO", "BAR"]