hello, i have a function that was written out for me in asp. i am trying to convert it to js but am getting confused with the double IF syntax, can somebody assist me in converting this to javascript:

Code:
D = "W1K 1BE"
DL = Instr(D," ") 
Dleft = left(D,DL - 1)
Dleft2 = left(Dleft,2)
Dright2 = mid(Dleft,3)
Dright2len = len(Dright2)
i = 1
Dright2end = Dright2

Do While i <= Dright2len 
	strcheck = mid(Dright2,i,1)

	if IsNumeric(strcheck) 	then
		Dright2end = Dright2end
	else 
				
                         strcheckexists = Instr(Dleft2,strcheck)
if strcheckexists = 0 then 

			Dright2end = Replace(Dright2end,strcheck,"")
		end if
	end if	
	i = i +1 
Loop

strfinal = Dleft2 &  Dright2end
thanks