6. Block Scope III - A question

const starCount = () => {
  let i = 5;
  for (let i = 0; i < 12; i++) {


Question: Is the variable “i” in the “for” loop completely different from the one at the top of the function, or are they the same but the “for” one is overriding the first one?

i’m asking this, because if I remember correctly, in other languages(I think C#) you can have different variables with the same name as long as they’re not sharing the same scope.

(also, an aside: This exercise asks for the student to create a “For loop” even though it hasn’t been introduced yet. Following the Syllabus, “Loops” come after “Scope”.)


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.