# 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)

###

###


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://leeboa.gitbook.io/study/undefined/clock-part-one.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
