{"size": 824, "ext": "js", "max_stars_repo_path": "Closures_Scopes/src/scope/block.js", "max_stars_repo_name": "DannielF/Development_Engineering", "max_stars_repo_stars_event_min_datetime": "2020-09-11T16:29:05.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-11T16:29:05.000Z", "max_issues_repo_path": "JavaScript/Closures_Scopes/src/scope/block.js", "max_issues_repo_name": "DannielF/Dev_web", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "JavaScript/Closures_Scopes/src/scope/block.js", "max_forks_repo_name": "DannielF/Dev_web", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 18.7272727273, "max_line_length": 65, "alphanum_fraction": 0.572815534}
// block scope
const fruits = () => {
  if (true) {
    var fruits1 = 'apple'; // se puede acceder en toda la funcion
    let fruits2 = 'banana'; // dentro del block scope
    const fruits3 = 'kiwi'; // dentro del block scope
    console.log(fruits2);
    console.log(fruits3);
  }
  console.log(fruits1);
};

fruits();

let x = 1; // valor global
{
  let x = 2; // valor local
  console.log(x);
}
console.log(x);

// se esta reasignando var con el ultimo valor 10.
// se imprime entonces 10, 10 veces.
const anotherFunction = () => {
  for (var i = 0; i < 10; i++) {
    setTimeout(() => {
      console.log(i);
    }, 1000);
  }
};

anotherFunction();

// forma correcta
const anotherFunction = () => {
  for (let i = 0; i < 10; i++) {
    setTimeout(() => {
      console.log(i);
    }, 1000);
  }
};

anotherFunction();
