$form.addEventListener('submit', (event) => {
event.preventDefault(); // 기본 동작 막기
console.log('submit');
const value = $input.value;
$input.value = '';
if(!checkInput(value)){
return;
}
// 배열을 문자로
if(answer.join('') === value) { // [3, 1, 4, 6] -> '3146'
$logs.textContent = '홈런!';
return;
}
if(tries.length >= 9){
const message = document.createTextNode(`패배! 정답은 ${answer.join('')}`);
$logs.appendChild(message);
return;
}
tries.push(value);
});
배열을 문자열로 바꾸는 메서드

문자열을 배열로 바꾸는 메서드

'1'을 기준으로 나누기 때문에 ['3','46'] 값이 나온다.
'3146'.split('1'); // ['3','46']
각각 텍스트와 태그를 만드는 메서드이다.
단, 다른 태그에 append 나 appendChild 를 하기 전까지는 화면에 보이지 않는다.
텍스트 = document.createTextNode(데이터);
텍스느 노드를 생성한다.
let element = document.createElement(tagName[, options]);
지정한 tagName의 HTML 요소를 만들어 반환한다.
tagName을 인식할 수 없으면 HTMLUnknownElement (en-US)를 대신 반환한다.
두 메서드는 모두 부모 자식에 자식 노드를 추가하는 메서드이나 차이점은 자식 노드를 추가하는 방식이다.
마지막 자식 뒤에 개체 또는 문자열 개체 Element.append()집합을 삽입합니다.
문자열 개체는 동등한 노드로 삽입됩니다.
텍스트를 추가할 때 document.createTextNode 대신 문자열을 바로 넣어도 된다.



append는return값을 반환하지 않는다.
append 와 다르게 노드 객체(node object) 만 받을 수 있다.하나의 노드 만 추가할 수 있다.

🚨 type error 발생
node 유형이 아니라서 appendChild 를 실행하지 못했다는 타입 에러가 발생한다.
if(tries.length >= 9){
const message = document.createTextNode(`패배! 정답은 ${answer.join('')}`);
$logs.appendChild(message);
return;
