Skip to main content
Code Review

Return to Answer

I'd prefer writing it like this:

dataSearcher = (dataElementelement, identifier) -> 
 return element if element.identifier is identifier
 for child in element.children
 found = dataSearcher child, identifier
 return found if found

Changes:

  • guard style instead of else (one less level of indentation)
  • postfix if (probably a question of style)
  • is instead of ==
  • shorter variable names

I'd prefer writing it like this:

dataSearcher = (dataElement, identifier) -> 
 return element if element.identifier is identifier
 for child in element.children
 found = dataSearcher child, identifier
 return found if found

Changes:

  • guard style instead of else (one less level of indentation)
  • postfix if (probably a question of style)
  • is instead of ==
  • shorter variable names

I'd prefer writing it like this:

dataSearcher = (element, identifier) -> 
 return element if element.identifier is identifier
 for child in element.children
 found = dataSearcher child, identifier
 return found if found

Changes:

  • guard style instead of else (one less level of indentation)
  • postfix if (probably a question of style)
  • is instead of ==
  • shorter variable names
Post Migrated Here from stackoverflow.com (revisions)
Source Link
thejh
  • 196
  • 3

I'd prefer writing it like this:

dataSearcher = (dataElement, identifier) -> 
 return element if element.identifier is identifier
 for child in element.children
 found = dataSearcher child, identifier
 return found if found

Changes:

  • guard style instead of else (one less level of indentation)
  • postfix if (probably a question of style)
  • is instead of ==
  • shorter variable names
lang-js

AltStyle によって変換されたページ (->オリジナル) /