Consider following code snippet:

var result = 0;
function AddValue(x) {
    result = result + x;
    return result;
}
console.log(AddValue(AddValue(10)));
What will be printed to the console?
Explanation
Variable result declared in global scope. first function invoke: result = result + x; // result = 0 + 10; second function invoke: result = result + x; // result = 10 + 10;

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести