Updating orders with status change

JavaScript Medium objects

Task «Updating orders with status change»

Given an array of order objects. Each order contains fields: id (number), status (string), items (array of strings). It is necessary to write a function that takes an array of orders and a string of the new status. The function should return a new array where each order containing at least one element in items has its status changed to the new one. Orders with empty items do not have their status changed. The original array must not be modified.

Input Format

First line — the new status string. Second line — a JSON array of order objects.

Output Format

JSON array of updated orders.

main.js