diff --git a/1-js/05-data-types/10-date/7-get-seconds-to-tomorrow/solution.md b/1-js/05-data-types/10-date/7-get-seconds-to-tomorrow/solution.md index a89c8b3e..dd8ba927 100644 --- a/1-js/05-data-types/10-date/7-get-seconds-to-tomorrow/solution.md +++ b/1-js/05-data-types/10-date/7-get-seconds-to-tomorrow/solution.md @@ -13,3 +13,19 @@ function getSecondsToTomorrow() { return Math.round(diff / 1000); // convert to seconds } ``` + +Alternative solution: + +```js run +function getSecondsToTomorrow() { + let now = new Date(); + let hour = now.getHours(); + let minutes = now.getMinutes(); + let seconds = now.getSeconds(); + let totalSecondsToday = (hour * 60 + minutes) * 60 + seconds; + let totalSecondsInADay = 86400; + + return totalSecondsInADay - totalSecondsToday; +} + +```