File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
18 - Adding Up Times with Reduce Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 181181 Video 58
182182 </ li >
183183
184- < script >
185- </ script >
184+ < script src ='js/app.js '> </ script >
186185</ body >
187186</ html >
Original file line number Diff line number Diff line change 1+ const timeNodes = Array . from ( document . querySelectorAll ( '[data-time]' ) ) ;
2+ const seconds = timeNodes
3+ . map ( node => node . dataset . time )
4+ . map ( timeCode => {
5+ const [ mins , secs ] = timeCode . split ( ':' ) . map ( parseFloat ) ;
6+ return mins * 60 + secs ;
7+ } )
8+ . reduce ( ( total , vidSeconds ) => total + vidSeconds ) ;
9+
10+ let secondsLeft = seconds ;
11+ const hours = Math . floor ( secondsLeft / 3600 ) ;
12+ secondsLeft = secondsLeft % 3600 ;
13+ const mins = Math . floor ( secondsLeft / 60 ) ;
14+ secondsLeft = secondsLeft % 60 ;
15+ console . log ( hours , mins , secondsLeft ) ;
You can’t perform that action at this time.
0 commit comments