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" checks forces you to use "var" cannot use "let" or "const"

See original GitHub issue

Challenge Name

https://beta.freecodecamp.org/en/challenges/basic-javascript/iterate-through-an-array-with-a-for-loop

Issue Description

The challenge requires you to initialize a variable however it forces you to use var, rather than let or const.

Browser Information

  • Browser Name, Version: Ungoogled Chromium
  • Operating System: macOS
  • Mobile, Desktop, or Tablet: Desktop

Your Code


N/A

Screenshot

screen shot 2018-03-29 at 1 23 37 pm

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
raisedadeadcommented, Apr 2, 2018

I think I incline towards adding support for let. But it doesn’t have to be explicit or obvious, even in the test message. As long as we can keep that I am okay to update the tests.

1reaction
germangamboa95commented, Mar 30, 2018

It is looking for a specific solution that uses the var keyword.

        "assert(code.match(/var.*?total\\s*=\\s*0.*?;/), 'message: <code>total</code> should be declared and initialized to 0');"
      ]

As a side note, a lot of the beginning javascript challenges force you to use var. I am pretty sure this is by design.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Loops and iteration - JavaScript - MDN Web Docs
The for...of statement creates a loop Iterating over iterable objects (including Array , Map , Set , arguments object and so on), invoking...
Read more >
javascript - Why is using "for...in" for array iteration a bad idea?
Using for (var property in array) will cause array to be iterated over as an object, traversing the object prototype chain and ultimately...
Read more >
JS For Loop Tutorial – How to Iterate Over an Array in JavaScript
This article will provide you with a solid understanding of exactly how to iterate over an Array data structure in JavaScript.
Read more >
Is it best to use "var" or "let" in for loop iterations or ... - Reddit
In a for-of loop, const does work to store the list item in our current iteration. It's essentially scoped to each iteration, so...
Read more >
5. Working with Arrays and Loops - JavaScript Cookbook [Book]
For instance, if you create an array literal, you can use commas to delimit array elements that don’t yet exist: var arrLiteral =...
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