Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
190
rated 0 times [  193] [ 3]  / answers: 1 / hits: 52124  / 8 Years ago, mon, november 21, 2016, 12:00:00

I´m trying to set some values within a object using forEach lambda:



 var row = {title: , attribute:, width: };
list.forEach( list =>
row.title = list.label |
row.attribute = list.label |
row.width = 300px
);


Works fine only with a statement row.title = list.label when I add the rest of parameters does not work fine.



What is the right syntax?


More From » foreach

 Answers
27

Try:



 var row = {title: , attribute:, width: };
list.forEach( list => {
row.title = list.label;
row.attribute = list.label;
row.width = 300px
});


Notice the curly braces.


[#59984] Friday, November 18, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dayshadelaniej

Total Points: 668
Total Questions: 121
Total Answers: 121

Location: Sao Tome and Principe
Member since Wed, Dec 21, 2022
1 Year ago
;