Subj : Question about string.trim() To : echicken From : KenDB3 Date : Thu Sep 08 2016 12:32 pm Re: Question about string.trim() By: echicken to KenDB3 on Thu Sep 08 2016 11:39 am >> So, my first question is, is the trim() function valid in JavaScript >> 1.8.5? I'm guessing it is because it's been working in ec> Yes, it's a valid method on a String object. Awesome, thank you. >> What I find interesting is that the error flagged on a trim() on line >> 275, but was OK with the trim() on line 270: timestamp.trim(). ec> In this case 'timestamp' is really just another String, since you're just ec> grabbing the text from the feed and not turning it into a Number or Date ec> object, so that makes sense. ec> My best guess is that the 'solarflux' value was absent when this person ec> fetched the feed, or that they failed to fetch the feed altogether. On ec> line 80, if 'solardata.solarflux' is undefined, 'sfi' gets set to 0, a ec> Number, which does not have the '.trim()' method. Wrap that 0 in quotes on ec> line 80 and this particular problem should go away. ec> Also, if you wanted to, you could also shorten things a bit by doing ec> something like: ec> var sfi = solardata.solarflux || '0'; ec> var sfi_int = parseInt(sfi); ec> var ai = solardata.aindex || 'No Data'; ec> // etc. ec> That would be like a shorter version of: ec> var sfi = (typeof solardata.solarflux == 'undefined' ? '0' : ec> solardata.solarflux); ec> Which is a shorter version of: ec> var sfi = solardata.solarflux; ec> if (sfi == undefined) { ec> var sfi = '0'; ec> } You make it look so easy! Thanks man, that's incredibly helpful, I really appreciate it. I'm learning lots playing with this stuff. I had a feeling, but I wasn't sure. Updates imminent :-) ~KenDB3 --- þ Synchronet þ KD3net-Rhode Island's only BBS about nothing. http://bbs.kd3.us .