By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,648 Members | 1,489 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,648 IT Pros & Developers. It's quick & easy.

Do-while to For-if loop

P: 2
can somebody convert :

do {

newNumber = columnMultiple + getNewNumber() + 1;
}
while(usedNumbers[newNumber]);{

if (!usedNumbers[newNumber]) {

usedNumbers[newNumber] = true;

document.getElementById(currentSquare).innerHTML = newNumber;
}
}



to a for loop code
Mar 17 '12 #1
Share this Question
Share on Google+
3 Replies


10K+
P: 13,264
1.) Java != Javascript
2.) Use code tags when posting code
3.) What have you tried?
Mar 17 '12 #2

P: 2
i tried to use

for(newNumber>0; usedNumbers[newNumber]; newNumber++){
if (!usedNumbers[newNumber]) {
document.getElementById(currentSquare).innerHTML = newNumber;
}
}
Mar 17 '12 #3

P: 51
//try this..

newNumber = columnMultiple + getNewNumber();

for(usedNumbers[newNumber] = true;usedNumbers[newNumber] = false;newNumber = newNumber + 1) {
if(!usedNumbers[newNumber]) {
usedNumbers[newNumber]=true;
document.getElementById(currentSquare).innerHTML=n ewNumber;
}
}

//i hope it helps..

for(initialization;condition to terminate loop;inc/dec ++/--) {
statements to do or what will happen when looping occured..
}

//good luck! =)
Mar 17 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.