Jump to content
Larry Ullman's Book Forums
Max

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!

Share this post


Link to post
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

Share this post


Link to post
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).

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...