Thursday, January 3, 2013

Javascript equivalent for Do While loop in vbscript


VB script -
1. The do while statatement repeat a block of code until condition is true,


Do While nI>10
nI = nI + 1
Loop


If nI equals 9, above code will not be excuted,

2. This block of condition excuted at least once

Do 
nI = nI + 1
Loop While nI>10

Even nI is less than 10, the block of code is excuted once.

Javascript -


1.This block of code is equalant to above first vbscript example


while (nI>10)
  {
  nI = nI ++;
  }

2.This block of code is equalant to above second vbscript example

do
  {
nI = nI ++;
  }
while (nI>10);

This code also excuted once whether condition is failed or not


No comments:

Post a Comment