Päivän loppu JavaScriptissä

Saadaan päivämääräolio, joka sisältää nykyisen päivän lopun:

javascriptlet now  = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59);

Nykyisen päivän lopuksi voidaan laskea seuraavan päivän keskiyö (ero on 1 sekunti):

javascriptlet now  = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 0);

Kuten tiedät, nollia voidaan tässä tapauksessa jättää pois:

javascriptlet now  = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1);

Muuten, keskiyö on myös nykyisen päivän aika 24:00:00:

javascriptlet now  = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 24, 0, 0);

Jätetään nollat pois:

javascriptlet now  = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 24);
Задание 1

Määritä, kuinka monta tuntia on jäljellä päivän loppuun.