Q:

Global variable not updating when I assign it a value within a function

I am trying to create an array based off lines in a .txt file using jQuery. The array is a list of answers for a game.
The console is logging an array with content the first time but an empty array the second time. Why is answers not updating globally?
Here is my code:
//create global variable answers
var answers = new Array;
//assign a value to answers from text file
$.get("wordsEn.txt", function(txt){
    answers = txt.split('\n');
    console.log(answers);
});
console.log(answers);

A:

You need to call a function insite the synchronously function somthing like 
    //create global variable answers
var answers = new Array;
var cb = function(){
    console.log(answers);
};
//assign a value to answers from text file
$.get("wordsEn.txt", function(txt){
    answers = txt.split('\n');
    console.log(answers);
    if(cb)
        cb();
});

