Learning Web App Development

by Semmy Purewal

duplicate variable declaration

page 108

17 May 2014

On page 108, the variable $new_comment is inadvertently declared with in two var statements. It should only be declared above the if statement. The corrected code looks like this:

var $new_comment;

if ($(".comment-input input").val() !== "") {
    $new_comment = $("<p>").text($(".comment-input input").val());
    $(".comment-input input").val("");

Thanks to Ken Hommel for reporting this.