File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
src/week3/7-oop/nobel-prize-simple Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 1919 }
2020
2121 async fetchData ( ) {
22- const newState = { ... this . state , error : null } ;
22+ this . state . error = null ;
2323 try {
2424 const { laureates } = await Model . fetchJSON ( API_URL ) ;
25- newState . laureates = laureates ;
25+ this . state . laureates = laureates ;
2626 } catch ( err ) {
27- newState . error = err ;
27+ this . state . error = err ;
2828 }
29- this . state = newState ;
3029 this . notify ( this . state ) ;
3130 }
3231
Original file line number Diff line number Diff line change 2727 id : 'list-container' ,
2828 } ) ;
2929 laureates . forEach ( laureate => {
30+ const prizeYears = laureate . prizes
31+ . reduce ( ( acc , prize ) => acc . concat ( prize . year ) , [ ] )
32+ . join ( ', ' ) ;
3033 View . createAndAppend ( 'li' , ul , {
3134 class : 'list-item' ,
32- text : `${ laureate . firstname } ${ laureate . surname || '' } ` ,
35+ text : `${ laureate . firstname } ${ laureate . surname ||
36+ '' } (${ prizeYears } )`,
3337 } ) ;
3438 } ) ;
3539 }
You can’t perform that action at this time.
0 commit comments