Since local variables are only recognized inside their functions, variables with the same name can be used in different functions.
Local variables are created when a function starts, and deleted when the function is completed.
"use strict";
x = 3.14; // This will cause an error (x is not defined)
x = 6;
x = x * 2 + 1;
var x;
var x;
x = 6;
x = x * 2 + 1;
The same
http://www.jslint.com/ JSLint
http://jshint.com/ JSHint
https://learn.javascript.ru/functions-closures Замыкания, область видимости
John Resig - Secrets of the JavaScript Ninja - Книга
http://gabdrahimov.ru/javascript-oglavlenie JS Учебник
http://habrahabr.ru/post/38642/ Замыкания в JavaScript
https://developer.mozilla.org/ru/docs/Web/JavaScript/Closures Замыкания
You can find the task on OneDrive.