The solution to this problem of course is to check whether or not the variable has already been initiated. And this can easily be accomplished with the help of an if statement. Here is how it's done:
var yourVariable = "Some text here!";
As you can see from the code above, with if(!yourVariable) we check as to whether or not the variable yourVariable already exists. Since it does not we initiate it, and upon this call upon alrert() to display it in an alert box. This way you are guaranteed not to overwrite, or redefine, previously defined variables.