{word}
);\n }\n\n // update currentWord state\n letterHandler(letter) {\n if(this.state.displayingMessage)\n {\n this.setState({\n currentWord: letter,\n displayingMessage: false\n });\n return;\n }\n\n // max word length\n if (this.state.currentWord.length >= 18) {\n this.setState({ currentWord: '' });\n this.displayMessage('Too long.');\n return;\n }\n this.setState({ currentWord: \n this.state.currentWord === 'spelling bee' ? letter : this.state.currentWord+ letter \n });\n }\n\n // check entered word for correctness\n enterHandler() {\n if (this.state.currentWord.length === 0) return;\n // clear old word\n this.setState({ currentWord: '' });\n\n // success conditions\n // USE OBJ\n const successConditions = {\n 'Too short.': this.state.currentWord.length < 4,\n 'Not in list.': !this.state.wordList.hasOwnProperty(this.state.currentWord),\n 'Aready found.': this.state.wordList[this.state.currentWord]\n };\n\n for (const message in successConditions) {\n if (successConditions[message]) {\n this.displayMessage(message);\n return;\n }\n }\n\n // mark word as found\n let wordList = this.state.wordList;\n wordList[this.state.currentWord] = true;\n this.setState({ wordList: wordList });\n }\n\n deleteHandler() {\n if(this.state.currentWord.length === 0) return;\n this.setState({ currentWord: this.state.currentWord.slice(0, -1) });\n }\n\n displayMessage(message) {\n this.setState({ \n currentWord: message,\n displayingMessage: true \n });\n\n // clear message\n setTimeout(\n () => this.setState({ \n currentWord: this.state.displayingMessage ? '' : this.state.currentWord,\n displayingMessage: false\n }),\n 1500);\n }\n\n render() {\n return (\n:
{this.state.currentWord}
}\n\n {Object.keys(this.state.wordList).filter(key => \n this.state.wordList[key]).length}/{Object.keys(this.state.wordList).length}\n
\n\n {/* show all words found */}\n {\n Object.keys(this.state.wordList).filter(\n key => this.state.wordList[key]).map(word =>{word}
)\n }\n