question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Iterate Through an Array with a For Loop - Multiple Initializations

See original GitHub issue

Challenge Iterate Through an Array with a For Loop has an issue. User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36. Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:


// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

for (var i = 0; i < ourArr.length; i++) {
  ourTotal += ourArr[i];
}

// Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line

for (**var total = 0**, i = 0; i < myArr.length; i++) {
  total += myArr[i];
}


Multiple initialization not accepted as correct solution.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
raisedadeadcommented, Dec 12, 2016

Okay, just confirmed. The changes are on staging via https://github.com/FreeCodeCamp/FreeCodeCamp/commit/f8425780ec0f9866354e5ce23e745a2d5e9f6ebc

And the blame on Line 5268 and others is still yours.

Basically, this should get fixed when we merge to master during future release?

0reactions
systimoticcommented, Sep 5, 2017

Closing as this has been resolved in the beta. Happy coding!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using multiple variables in a for loop in Python - Stack Overflow
I would argue that the simplest way of iterating over a list in Python is to omit indices altogether: for i in array:...
Read more >
Multiple Initializations and Increments in for loop Easy Way Lec
In the discussion on for loop, only one variable has been initialized and incremented in the initialization and increment part of the loop....
Read more >
Multiple Initializations and Increments in for loop | Lesson 38.2
In this class, we will try to understand Multiple Initializations and Increments in for loop. We have already discussed the concept of for ......
Read more >
Iterating an Array using a For Loop - Appficial - YouTube
It is common to iterate through the elements of an array. A for loop is typically used to access every element of the...
Read more >
For Statement (The GNU Awk User's Guide)
The for statement makes it more convenient to count iterations of a loop. The general form of the for statement looks like this:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found