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

# 끝말잇기 구현

1. **순서도 그리기**

![끝말잇기 순서도](/files/-MFLYRuv7-LZ1i7o91os)

**2. 코드로 구현**

```javascript
var word = '제로초'
while(true) {
    var newWord = prompt(word);//사용자로부터 입력받는다.
    if(word[word.length - 1] === newWord[0]){
        alert('딩동댕');
        word = newWrod;
    } else {
        alert('땡')
    }
}
for (var word = '제로초' ; true; ) {
    var answer = prompt(word)
    if(word[word.length - 1] === newWord[0]){
        alert('딩동댕');
        word = newWrod;
    } else {
        alert('땡')
    }
}
```
