You could do something like this instead. It's more compact, but it might be less readable. Up to you.

```javascript
result = resultsByDate[results[i].date] || {date: results[i].date};
result[results[i].code] = results[i].value;
resultsByDate[results[i].date] = result;
```