Skip to content

Commit 3dc4b5e

Browse files
committed
String concat code blocks were not equivalent.
If the array is empty, the "bad" code will return `<ul></ul>` and the "good" code will return `<ul><li></li></ul>`. Although I would prefer this over the for loop: function inbox(messages) { items = messages.map(function(message) { return '<li>' + message.message + '</li>'; }); return '<ul>' + items.join('') + '</ul>';
1 parent d8564cf commit 3dc4b5e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,10 @@
250250
items = [];
251251
252252
for (i = 0; i < length; i++) {
253-
items[i] = messages[i].message;
253+
items[i] = '<li>' + messages[i].message + '</li>';
254254
}
255255
256-
return '<ul><li>' + items.join('</li><li>') + '</li></ul>';
256+
return '<ul>' + items.join('') + '</ul>';
257257
}
258258
```
259259

0 commit comments

Comments
 (0)