PDA

View Full Version : Please explain this line of code...


HappyTomato
12-31-2002, 12:22 AM
hi all:

we encountered this block of javascript code but we don't understand a line within this block.... can somebody explain to us what it means??

====from this block of code=========

while (ls.length>12){
ab=eval(ls.substring(0,2))-89;
----->this line---ab1=(ab1==""?""+ab:ab1); <---------
oab1=ab1;
ls=ls.substring(2,ls.length);
for (var i=0;i<ab;i++){
nr=eval(ls.substring(0,2))-a;
ls=ls.substring(2,ls.length);
nls+=al.charAt(nr);
}


================================


any help will be appreciated!!


Bo & Vic

caldasgsm
12-31-2002, 12:32 AM
thats a condicional operator known as the trinary operator(not shure how to write)...

it works like a if but in a single line

(condition?true_instruction:false_instruction)...
your could write that code like

if(ab1=="")
{
ab1 = ""+ab;
}
else
{
ab1 = ab1;
}