Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. this._ingredients = ingredients.reduce((acc: string, item: string, index: number) => {
  2. if (item === null || item === undefined) {
  3. throw new Error('No ingredients found!');
  4. }
  5.  
  6. if (index !== 0) {
  7. acc += `, ${item}`;
  8. } else {
  9. acc += item;
  10. }
  11.  
  12. return acc;
  13. }, '');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement