1. HTML 세팅하기

Untitled

2. 이벤트 리스너 달기

document.querySelector('input').addEventListener('input', (event) => {
      console.log('글자 입력함', event.target.value);
});

3. 첫 입력 값 사용하기

const $button = document.querySelector('button');
const $input = document.querySelector('input');
const $word = document.querySelector('#word');
let word; //제시어
let newWord; //새로 입력한 단어

const onClickButton = () => {
      if (!word) {
        //비어있는 경우 
        word = newWord;
        $word.textContent = word;
				$input.value = '';
      } else {
        //비어있지 않은 경우
      }
    }
const onInPut = (event) => {
  newWord = event.target.value;
  }
$button.addEventListener('click', onClickButton);
$input.addEventListener('input', onInPut);

4. 올바른 단어인 지 확인하기

if (word[word.length - 1] === newWord[0])

Untitled

5. 순서