Challenge for Functions, Scope and Closures
Challenge
You found a mysterious piece of convoluted code that calculates and prints theAnswer. What will it print?
universe = 1;  //global variable
function getEverything(){
    var life = 22; //declared in function
    return life;
}
function doubleUniverse(){
    universe = universe * 2;
}
//double universe 4 times
for(var life=0; life<4; life++){  
    doubleUniverse(); 
}
var everything = getEverything();
var theAnswer = life + universe + everything;
console.log(theAnswer);
Please sign in or sign up to submit answers.
Alternatively, you can try out Learneroo before signing up.