Jump to content



Photo
- - - - -

Ch- 7 Creating Functions Question


  • Please log in to reply
2 replies to this topic

#1 Khai

Khai

    Newbie

  • Members
  • Pip
  • 2 posts
  • LocationNew York

Posted 16 August 2012 - 3:09 PM

Hello! I'm loving this book on Javascript. It was given to me and probably the best book I've read on javascript! (I'm still new at it) Although, I seem to be having a problem that I cant seem to figure out.
You know the exercies sorting an array with a user defined function? Well in the setText() function I was creating the IF statement for the elementId and message.

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

The problem is that the output.textContent and the innerText that are assigned to numbers doesn't seem to work! The "numbers' don't seem to be assigned to a value. As it says "Unresolved variable or type."

This happened in the last exercies I did with the modefied days.js. Any help would be awesome!

Thanks
  • 0

#2 Khai

Khai

    Newbie

  • Members
  • Pip
  • 2 posts
  • LocationNew York

Posted 17 August 2012 - 2:15 AM

Never mind, I solved it. I had to change the assignment of the output.innerText to message instead of numbers.
Don't understand why It said to assign it to numbers though.
  • 0

#3 Larry

Larry

    Administrator/Writer

  • Administrators
  • 3,538 posts
  • LocationState College, PA (USA)

Posted 18 August 2012 - 8:19 AM

Kudos for figuring it out. This was an error on my part, I believe: a late copy and paste that didn't get fixed. It's listed on the errata page, which you can check when you have a true mystery like this. Apologies for the confusion!
  • 0