Can a global variable be changed locally in Javascript?

The short answer to that is Yes.

Here is an example:

var sum = 0;

function addThree() {
sum = sum + 3;
}

//var=3

// Only change code below this line
function addFive(){
sum = sum +5
}

//var sum=8

// Only change code above this line

addThree();
console.log(sum)
addFive();

console.log(sum)

Without the use of the var keyword and hence being undefined, the variable sum inside functions addThree() and addFive() becomes a global variable meaning that once the value of sum changes inside the addThree() function it is also gets changed in the global variable which now becomes 3. The same is repeated after the function addFive()