August 2017
Beginner
298 pages
7h 4m
English
We are still missing time in our widget. Unlike other values, time does not depend on the HTTP request but it needs to be updated every second automatically. In your weather class, add the following method:
displayTime() { const date = new Date(); const displayTime = `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`; const $time = this.$shadowRoot.querySelector('#time'); $time.textContent = displayTime;}
The displayTime() method does the following:
Read now
Unlock full access