# What's wrong with my Phoenix LiveView code?

**URL:** <https://forum.devtalk.com/t/whats-wrong-with-my-phoenix-liveview-code/130914>\
**Category:** Backend Questions/Help\
**Tags:** elixir, liveview, phoenix\
**Created:** [3 November 2023 11:55 UTC](https://forum.devtalk.com/t/whats-wrong-with-my-phoenix-liveview-code/130914 "2023-11-03T11:55:29Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![pillaiindu](https://forum.devtalk.com/user_avatar/forum.devtalk.com/pillaiindu/32/6863_2.png) [@pillaiindu](https://forum.devtalk.com/u/pillaiindu)\
**Post date:** [3 November 2023 12:03 UTC](https://forum.devtalk.com/t/whats-wrong-with-my-phoenix-liveview-code/130914/2 "2023-11-03T12:03:01Z")

</div>

[Bard](https://bard.google.com) said to make the `handle_event` like this,

```auto
  def handle_event("guess", %{"number" => guess}, socket) do
    message = cond do
      guess == socket.assigns.random ->
        "Your guess: #{guess}. Correct!"
        {:noreply, assign(socket, random: random())}
      true ->
        "Your guess: #{guess}. Wrong. Guess again."
    end

      {:noreply, assign(socket, score: socket.assigns.score + 1, message: message, time: time())}
    end

```

but that didn’t work either.

---

_[View the full topic](https://forum.devtalk.com/t/whats-wrong-with-my-phoenix-liveview-code/130914)._
