Skip Navigation

You're viewing a single thread.

2 comments
  • It is because you are 'overwriting' the value of the state variable.

    Initially you have it as a list:

    state // state list
      Utah [state = "Utah", geo = "landlocked"]
      Arizona [state = "Arizona", geo = "landlocked"]
      Tennessee [state = "Tennessee", geo = "landlocked"]
      Alaska [state = "Alaska", geo = "coastal"]
      Florida [state = "Florida", geo = "coastal"]
    

    But after loading the page, it would automatically 'evaluate' the state list on the output in which it would evaluate to:

    [state] - random item from the `state` list -> Utah [state="Utah", geo = "landlock"] -> Utah landlock
    

    With the state = "Utah" in the square brackets, you are overwriting the state list to just have the value Utah in which after you click the randomize button, instead of it using the initial list, it would only just output Utah since it is the value that was assigned to the state variable.

    So, the solution would be like this:

    state
      Utah [geo = "landlocked", '']
      Arizona [geo = "landlocked", '']
      Tennessee [geo = "landlocked", '']
      Alaska [geo = "coastal", '']
      Florida [geo = "coastal", '']
    

    This list would output the state and then set the geo variable to its value. In [geo = "landlocked", ''], the , '' is there to have the square brackets output nothing (or an empty string).

    Since all square brackets, after evaluating it, always output the result in the square bracket, like in [state="Utah", geo = "landlock"], the last thing to be evaluated is the geo = "landlock", therefore the engine would output landlock on the page, so to prevent that we add an empty string at the end of the brackets.