Just Google for JavaScript tutorial and you will get more info than you want.
Not that I am a JavaScript writer but I think what might be confusing to people is the single line IF statement format, which took me some time to find a tutorial about this format.
See http://javascript.about.com/od/decisionmaking/a/des10.htm for more info.
But what is happening is that the normal IF/THEN/ELSE syntax like the following
IF (condition)
THEN
true-value
ELSE
false-value
is getting converted to a one line statement like
(condition) ? true-value : false-value;
Example:
If you had this IF/THEN/ELSE statement
IF ((albumartist.length>0 )
THEN
albumartist=albumartist + ’ ~ ’
ELSE
IF (artist.length>0)
THEN
artist = artist + ’ ~ ’
ELSE
artist= ’ ’
could be converted to a one line statement like
(albumartist.length>0 ? albumartist
+’ ~ ’ :(artist.length>0 ? artist + ’ ~ ’ : ’ '))
where
( ) / encloses the IF statement (IF)
? / start of the true condition (THEN)
: / start of the false condition (ELSE)
.length / is a built in function that returns the length of the variable that it is attached to. So artist.length returns the number of characters in artist. >0 is checking to see if that number is greater than zero. see (http://www.tizag.com/javascriptT/javascript-string-length.php) for more information on this function and others
- / is a concatenation symbol. So if artist = “robert” then
artist + ’ ~ ’ would be “robert ~”
It might help if you write what you want to do in the IF/THEN/ELSE format then go back and put it in the one line format.
Hope you are not more confused. The two URLs will give you more information.
Robert ~