const inventory = {
items: ['apple', 'banana', 'orange'],
[Symbol.iterator]: function() {
let index = 0;
const items = this.items;
return {
next: function() {
return index < items.length ?
{ value: items[index++].toUpperCase(), done: false } :
{ done: true };
}
};
}
};
const result = [...inventory].join(' + ');
console.log(result);
Ответ: APPLE + BANANA + ORANGE
JavaScript test | #JavaScript & Max