Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

joeframbach
Copy link
Contributor

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>';

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>';
@goatslacker
Copy link
Collaborator

👍 for no for-loop.

@goatslacker
Copy link
Collaborator

@hshoff keep it for-loopy or change to a more functional approach?

@hshoff
Copy link
Member

hshoff commented Mar 27, 2015

Would love to go functional approach with .map but we still support IE8 and we'd have to talk about adding a polyfill or something similar. Let's keep the for loop for now and avoid the for loops in the ES6 guide.

Thanks for this @joeframbach! 🍻

hshoff added a commit that referenced this pull request Mar 27, 2015
String concat code blocks were not equivalent.
@hshoff hshoff merged commit aad2bf8 into airbnb:master Mar 27, 2015
@joeframbach joeframbach deleted the patch-1 branch March 27, 2015 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants