import React, {useState} from "react"
/**
* Challenge:
*
* 1. Create state to hold the current value of the countdown timer.
* Display this time in the "Time Remaining" header
*/
function App() {
const [text, setText] = useState("")
function handleChange(e) {
const {value} = e.target
setText(value)
}
function calculateWordCount(text) {
const wordsArr = text.trim().split(" ")
return wordsArr.filter(word => word !== "").length
}
return (
<div>
<h1>How fast do you type?</h1>
<textarea
onChange={handleChange}
value={text}
/>
<h4>Time remaining: ???</h4>
<button onClick={() => console.log(calculateWordCount(text))}>Start</button>
<h1>Word count: ???</h1>
</div>
)
}
export default App