Momentum Project : Part1 : Making a Clock

itssweetrain·2021년 1월 8일
0

mini project

목록 보기
1/6
post-thumbnail
post-custom-banner

첫 JavaScript 실습 예제 (o´〰`o)♡✲゚

index.html

<div class = "js-clock">
    <h1>00:00</h1>
</div>

<script src="clock.js"></script>

Q1.

const clockContainer = document.querySelector('.js-clock');
const clockTitle = clockContainer.querySelector('h1');

Can we directly go for clockTitle = document.querySelector("h1"); instead of making const clockContainer? Yes!

He use clockContainer.querySelector("h1") because he think document.querySelector("h1") is too general and maybe I might have another h1 on the document.

💡 What I learned

  • new Date() 함수

  • ternary operator (or mini if)
    ${second < 10 ? 0${seconds} : seconds}

  • setInterval(function, howOftenTheFunctionShouldExecute)

profile
motivation⚡️
post-custom-banner

0개의 댓글