반복
function sayHello() {
console.log("hello");
}
setInterval(sayHello, 5000);
일정시간 후 한번 호출
function sayHello() {
console.log("hello");
}
setTimeout(sayHello, 5000);
string 길이에 따라 앞에 문자 추가
"1".padStart(2,"0")→ “1”의 길이가 2가 아닐경우 앞에 0을 추가
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
const seconds = String(date.getSeconds()).padStart(2, "0");
clock.innerText = `${hours}:${minutes}:${seconds}`;