Hi,
I’m trying to solve the challenge in the first chapter of Programming Phoenix LiveView book. The challenge asks for altering the code so that a random number is set as the right guess and when the user clicks that number, it tells the user the number is correct.
Did anyone solve this challenge already?
I asked the same qusetion here five days ago, but didn’t yet get an answer.
def handle_event(“guess”, %{“value”=>value}, socket) do
if socket.assigns.number == value do
… :win → true, reset number, increase score
else
… You might hold a counter for wrong guess …
end
end
simply check @win in the template, with conditional rendering of reset links…
Thank you for your replies!
I’m not in the live_patch lesson yet and I don’t know how to use it.
I will follow your other suggestions and suggestions give by someone to the other post.