Home javascript How to pull the variable from the "FOR" cycle. JS

How to pull the variable from the “FOR” cycle. JS

Author

Date

Category

I write code:

for (var i = 0; i & lt; btnadd.length; i ++) {
   Let Plusall = Btnadd [i];
}
Console.log (plusall); //does not work

How to make that I could use the Plusall variable in other functions or anywhere else.


Answer 1

Release Let Plusall Out of Cycle:

let plusall;
For (var i = 0; i & lt; btnadd.length; i ++) {
   Plusall = Btnadd [i];
}
Console.log (plusall);

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions