Byte is planning a vacation and wants to compare the weather in several cities at a glance. The server is the same as in the workshop: GET /api/weather?city=… (the name goes through encodeURIComponent) answers { city, temp, … }. It knows Oslo, Lisbon, Porto and Reykjavik, answers 404 for everything else, 500 for Errorville, and there's no network to Tundra.
Write an async weatherReport(cities) that returns:
ok — an array of { city, temp } for the cities that worked, in the order of cities, with the temperature rounded (Math.round (opens in a new tab));failed — the names of the cities (as given in cities) whose weather couldn't be loaded: 404, 500 or no network;warmest — the city with the highest (rounded) temperature among ok, the one earlier in cities on a tie; or null (opens in a new tab) if there are none.
Two conditions, like in a real app: one failed city must not break the whole report, and the requests go out at the same time, not one after another. The test checks it: right after the call, as many requests as there are cities must have been sent (startedAtOnce).