const obj = {
data: ['x', 'y', 'z'],
*[Symbol.iterator]() {
for (let i = this.data.length - 1; i >= 0; i--) {
yield this.data[i].toUpperCase();
}
}
};
const result = [];
for (const item of obj) {
result.push(item);
if (result.length === 2) break;
}
console.log(result.join('-'));
Ответ: Z-Y
JavaScript test | #JavaScript & Max