Jump to content
Larry Ullman's Book Forums

Tasks.Js And Tasks2.Js


Recommended Posts

Hi Larry

 

I was terribly confused when working through 'tasks.js' which I downloaded from your web site until I realized that 'tasks.html' was calling 'tasks2.js'......Am I missing something here as 'tasks.js' has the following code which doesn't seem to do anything but seems useful:...

 

// Update the page:

message = 'You have ' + tasks.length + ' task(s) in your to-do list.';

if (output.textContent !== undefined) {

output.textContent = numbers;

} else {

output.innerText = numbers;

}

 

P.S. The book is fantastic!

Link to comment
Share on other sites

Replace assignment to output to "message" (where it is "number").

output.textContent = message;

} else {

output.innerText =message;

}

 

"tasks.length " stores number of tasks entered so far. It is then updated in "message" variable. And the "message" variable's value is printed through this conditional.

  • Upvote 1
Link to comment
Share on other sites

Thanks for the nice words on the book and sorry for the confusion. tasks.html includes tasks2.js because there are two versions of that JavaScript file, both used by the same HTML. And as sonal pointed out, there's an error in that code (also listed on the errata page).

Link to comment
Share on other sites

 Share

×
×
  • Create New...