File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,7 +75,9 @@ function getGryffindorHousePeople(list) {
7575 let result = [ ] ;
7676 list . forEach ( ( person ) => {
7777 const { firstName, lastName, house } = person ;
78- if ( house === "Gryffindor" ) result . push ( `${ firstName } ${ lastName } ` ) ;
78+ if ( house === "Gryffindor" )
79+ result . push ( `
80+ ${ firstName } ${ lastName } ` ) ;
7981 } ) ;
8082 return result ;
8183}
@@ -84,11 +86,13 @@ function findTeachersHavingPets(list) {
8486 let result = [ ] ;
8587 list . forEach ( ( person ) => {
8688 const { firstName, lastName, pet } = person ;
87- if ( pet !== null ) result . push ( `${ firstName } ${ lastName } ` ) ;
89+ if ( pet !== null )
90+ result . push ( `
91+ ${ firstName } ${ lastName } ` ) ;
8892 } ) ;
8993 return result ;
9094}
9195
92- console . log ( getGryffindorHousePeople ( hogwarts ) ) ;
96+ console . log ( ... getGryffindorHousePeople ( hogwarts ) ) ;
9397
94- console . log ( findTeachersHavingPets ( hogwarts ) ) ;
98+ console . log ( ... findTeachersHavingPets ( hogwarts ) ) ;
Original file line number Diff line number Diff line change @@ -6,3 +6,23 @@ let order = [
66 { itemName : "Hot Coffee" , quantity : 2 , unitPricePence : 100 } ,
77 { itemName : "Hash Brown" , quantity : 4 , unitPricePence : 40 } ,
88] ;
9+
10+ function printReceipt ( order ) {
11+ let receipt = [ ] ;
12+ let total = 0 ;
13+ receipt . push ( `
14+ QTY ITEM TOTAL` ) ;
15+ order . forEach ( ( item ) => {
16+ const { itemName, quantity, unitPricePence } = item ;
17+ const itemTotal = ( quantity * unitPricePence ) / 100 ;
18+ total += itemTotal ;
19+ receipt . push ( `
20+ ${ quantity } ${ itemName . padEnd ( 20 ) } ${ itemTotal . toFixed ( 2 ) } ` ) ;
21+ } ) ;
22+ receipt . push ( `
23+
24+ Total: ${ total . toFixed ( 2 ) } ` ) ;
25+ console . log ( ...receipt ) ;
26+ }
27+
28+ printReceipt ( order ) ;
You can’t perform that action at this time.
0 commit comments