Errata

Opa: Up and Running

Errata for Opa: Up and Running

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 1
I. Coding a Mini Wikipedia > 5. Building the UI in HTML and CSS

Safari Books Online, I. Coding a Mini Wikipedia > 5. Building the UI in HTML and CSS > Example: A Guessing Game (at the end of the section)

EXCERPT FROM THE BOOK:

Here?s the complete code example:
function show_number(_) {
#response = <>I was thinking of {1 + Random.int(10)}</>
}

function page() {
<h1>Guess what is the number between 1 and 10 I'm thinking of?</h1>
<div id=#response onclick={show_number}>Click to find out!</div>
}

Server.start(Server.http, { title: "Guess", ~page })

SHOULD BE:

secret = 1 + Random.int(10);

function show(secret, _) {
guess = String.to_int(Dom.get_value(#guess));
message =
if (guess==secret) { <span class="success">Congrats! < /span> }
else if (guess<secret) { <>More than this</> }
else { <>Less than this</> };
#message = message;
}

function page() {
<h1>Guess what is the number I'm thinking of</>
<input id=#guess/>
<span onclick={show(secret, _)}>Check</>
<div id=#message/>
}

Server.start(Server.http, { title: "Guess", ~page })

Daniel M.  Jul 12, 2013