+ 2
How to loop with different values?
I have the code below please help me to create a loop with two values. Any help would be great! https://code.sololearn.com/WcUB4son26zu/?ref=app
10 Respostas
+ 10
Is this what you want?
for (a;a<=32;a++) {
for (b;b<=9;b++) {
if (someValue >= a) {
document.write("output "+b+" ON");
} else {
document.write("output "+b+" OFF");
}
}
}
+ 9
I think we need some more information... Could you describe what shall happen in your loop? I guess the solution is a nested loop, but I may be wrong...
+ 9
@Waren Sry, it's too late for me and I'm typing on my mobile. I hope someone else can help you. I've bookmarked the question, so if you cannot find a solution, I'll take a look at it again tomorrow. Just post then, I'll see it.
+ 7
for (var i = 0; i < 10; i++){
if(someValue >= i)
// output on (use i)
else
// output off (use i)
}
+ 3
Hello @Tashi N please check the JS code again I revised it... the JS code I want to shorten it into loop thing. Can you loop it?
+ 2
the a should loop from 20 to 32 and b should loop from 3 to 9
+ 2
Something like this?
for (a>=3; a <= 9; a++) {
if (someValue >= 14 + a * 2) {
document.write ("output "+a+" ON");
} else {
document.write ("output "+a+" OFF");
}
}
+ 1
@Tasha N.. you're right might be nested loop! but won't work.
+ 1
Here's additional info:
Loop the if else statement from different values. Check the javascript code for more info. I want to loop two values inside if-else I have used nested loop but that's horrible. It wont work. This code is for Arduino and I will convert it into C# if else statement the C# doesn't accept thr nested loop so how I can achieve it?
0
yeah I know but I want to loop two different values inside if else statement please check the code.