> For the complete documentation index, see [llms.txt](https://leeboa.gitbook.io/study/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://leeboa.gitbook.io/study/undefined/clock-part-one.md).

# Clock part One

### 시계만들기

```javascript
const clockContainer = document.querySelector(".js_clock"),//js_clock 을 선택
      clockTitle =  clockContainer.querySelector("h1"); // js_clock의 h1


function getTime(){
  const date = new Date(); //Date생
  const minutes = date.getMinutes(); // Date getMinutes을 minutes에 저장 
  const hours = date.getHours();
  const seconds = date.getSeconds();
  clockTitle.innerText=`${hours}:${minutes}:${seconds}`; 
};

 getTime(); // 현제 시간,분,초 로 h1에 출력이됨
```

### setInterval(함수명,실행할 시간)

```javascript
setInterval(fn,10000);  // 기본형

function sayHi(){
  console.log("sayHi");
};

setInterval(sayHi, 3000); // 3초마다 sayHi를 출력함
```

###

### 시,분,초가 10보다 작을때 앞에 0이라는 숫자 붙여주기

```javascript
const clockContainer = document.querySelector(".js_clock"),
      clockTitle =  clockContainer.querySelector("h1");


function getTime(){
  const date = new Date();
  const minutes = date.getMinutes();
  const hours = date.getHours();
  const seconds = date.getSeconds();
  clockTitle.innerText=`${hours < 10 ? `0${hours}` : hours }:${minutes < 10 ? `0${minutes}` : minutes }:${
     seconds < 10 ? `0${seconds}` : seconds }`;
//만약에 hours , minutes , seconds가 10보다 작다면  앞에 0 을 붙여줘
//? -> 참인지 거짓인지 
//확인한후 : -> 참일때는 : 전값을 리턴 거짓일때는 : 이후의 값을 리컨 (작은 if문 같은 역활)
  
};

 getTime();

function init(){

  getTime();
  setInterval(getTime, 1000); // 현재시간이 출력됨
};

init();
```

### localStorage

나의 브라우저에 저장된 정보들을 볼 수 있다.

![](/files/-M_YxaanN8Yh-OIZdmJw)

###

###
