Created
May 9, 2019 19:39
-
-
Save b-rodrigues/d0d505aa8412b2cb3b66a749f902d418 to your computer and use it in GitHub Desktop.
elm reverse, but it's not working
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Browser | |
import Html exposing (Html, Attribute, div, input, text, button) | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (onClick) | |
-- MAIN | |
main = | |
Browser.sandbox { init = init, update = update, view = view } | |
-- MODEL | |
type alias Model = | |
{ content : String, | |
reversed : String | |
} | |
init : Model | |
init = | |
{ content = "", | |
reversed = ""} | |
-- UPDATE | |
type Msg = Reverse | |
update : Msg -> Model -> Model | |
update msg model = | |
case msg of | |
Reverse -> | |
{ model | reversed = String.reverse model.content } | |
-- VIEW | |
view : Model -> Html Msg | |
view model = | |
div [] | |
[ input [placeholder "Text to reverse"] [] | |
, button [ onClick Reverse ] [ text "Reverse" ] | |
, div[] [ text model.reversed ] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nothing happens when clicking on the button