Jump to content
Larry Ullman's Book Forums
ionezation

Different Code In Book !

Recommended Posts

In Chapter 7 - Creating Function page number 237. The code in the book has a discrepency that is provided in source code. It took me 30mins to get on the conclusion. The difference was at line 

output.textContent = numbers;

Instead it would be output.textContent = message;

 

 

Here it is the code

 

This is in the book at page 237

function setText(elementId,message)
{
'use strict';


if ((typeof elementId == 'string')
&& (typeof message == 'string') ){
var output = $(elementId);
if(output.textContent !== undefined)
{
output.textContent = numbers;
} else {
output.innerText = numbers;
}
} // end of if
} // end of setText()

This is the working corrected one in source code :

 

function setText(elementId,message)
{
'use strict';


if ((typeof elementId == 'string')
&& (typeof message == 'string') ){
var output = $(elementId);
if(output.textContent !== undefined)
{
output.textContent = message;
} else {
output.innerText = message;
}
} // end of if
} // end of setText()

 

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.

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...