Skip to content

Commit

Permalink
Tidy up code addendum
Browse files Browse the repository at this point in the history
  • Loading branch information
Chalarangelo committed Jan 4, 2025
1 parent 6234705 commit c5b72fd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions content/snippets/js/s/complex-object-factories.md
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,10 @@ export default class Factory {
const data = { ...factoryBase };

desiredTraits.forEach(trait => {
if (typeof trait === 'string') Object.assign(data, traits[trait]);
else if (typeof trait === 'object') Object.assign(data, trait);
if (typeof trait === 'string')
Object.assign(data, traits[trait]);
else if (typeof trait === 'object')
Object.assign(data, trait);
else if (typeof trait === 'function')
Object.assign(data, trait(data));
});
Expand Down

0 comments on commit c5b72fd

Please sign in to comment.