This is my code:
var something = false; 
myFunction(something);    
function myFunction(x) {
    x = true;
}
It does not work, the boolean still remains false. What do I have to change so it will work?
This is my code:
var something = false; 
myFunction(something);    
function myFunction(x) {
    x = true;
}
It does not work, the boolean still remains false. What do I have to change so it will work?
 
    
    You are passing x by value and not reference. Give this a read http://snook.ca/archives/javascript/javascript_pass
 
    
    You are changing the x only in the scope of the function and not the something where it points to. You can do this by returning x and set that to something.
var something = false; 
something = myFunction(something);    
function myFunction(x) {
    x = true;
    return x;
}
console.log(something)
This will give true.
