# Function

## Function

**어떠한것의 기능 원하는 만큼 쓸 수 있는 코드이다.**&#x20;

&#x20;**console -> object ,  log -> fuction**

```javascript
function sayHello (e,a){ //(e) -> 외부에 있는 데이터를 읽는 함수를 만드는 방법 
console.log('HEllo',e,"you have" a);
//console.log함수는 argument를 무한하게 가질 수 있다.
};
sayHello("Nice",15); //Hello Nice you have 15
// Nice 는 argument 인자 이다.
console.log("Hi"); // Hi
```

## Function Fun

```javascript
function sayHello(name,age){
  console.log('HEllo'+ name + "you have" + age + "years old");
};

sayHello{"boo" , 17}; // Hello boo you have 17 years old

function sayHello(name,age){
  return(`HEllo ${name} you are ${age} years old`);
  // return -> 반환해줌 
};

const greetBoo = sayHello("Boo", "17") 

console.log(greetBoo);// Hello boo you have 17 years old



const calculator = {
  plus: function (a, b)[
    return a + b;
  }
}

const  calculator.plus(5,5)
console.log(plus) // 10
```

## Function DOM

**DOM(Document Object Model)형태로 변경이 가능함**&#x20;

```javascript
const title = document.getElementByld("title"); // document -> object
const title = document.quearySelector("#title") // id title을 지정 
title.innerHTML = "Hi js" // html에 Hi js 출력됨
// html을 DOM객체로 바꿀 수 있다. Html 수정할 수 있다. 
title.style.color = "blue"; // 글씨 색깔이 블루로 바뀜 
console.log(title); // title id값을 가진 html element를 불러냄 
console.log(title); // 해당 정보를 볼 수 있음 
document.title = "Hello" // 타이틀이 Hello로 바뀜
```
