Jump to content
Larry Ullman's Book Forums

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()

 

Link to comment
Share on other sites

 Share

×
×
  • Create New...