I am making a game in html and javascript and have used a 'console' I used IF statements to allow the user to navigate around the game. But, they have seemed to stop working. They allow the user to move around in the game. Why aren't the IF statements running and how can I fix this?
function runcmd(){
var user = document.getElementById('code').value;
if(user == 'clear'){
l1.innerHTML = '';
l2.innerHTML = '';
l3.innerHTML = '';
l4.innerHTML = '';
l5.innerHTML = '';
l6.innerHTML = '';
l7.innerHTML = '';
l8.innerHTML = '';
l9.innerHTML = '';
l10.innerHTML = '';
};
if(user == 'connect'){
var user = document.getElementById('code').value;
l1.innerHTML = 'Connecting to ' ;
l2.innerHTML = 'Connected to ' ;
connected = true;
l4.innerHTML = 'view bank';
l5.innerHTML = 'upload [virus]';
l8.innerHTML = 'disconnect [ip]';
if(user == 'disconnect'){
connected = false;
l1.innerHTml = 'Disconnected Safely...';
};
if(user == 'view bank'){
var pwrd = Math.floor( Math.random() * 1) - 10000;
var nam = Math.floor( Math.random() * 1) - 10000;
alert(pwrd);
alert(nam);
var uname = 'user' + nam;
var user = prompt('Username: ');
var pass = prompt('Password: ');
if(user == uname && pass == pwrd ){
}
};
if(user == 'upload'){
svirus= prompt('Enter Virus: ');
for(var key in boughtviruses) {
if(boughtviruses[key] == svirus) {
l1.innerHTML = 'Uploading ' + svirus;
l2.innerHTML = 'Virus Uploaded';
}else{
alert("You Don't Have This Virus!");
};
};
};
};
};
.console{
position: relative;
height: 250px;
width: 500px;
background-color: #000;
border-left: 10px solid #cccccc;
border-top: 5px solid #cccccc;
border-right: 10px solid #cccccc;
border-bottom: 10px solid #cccccc;
}
.exit {
float: right;
background: #800000;
color: white;
height: 25px;
border: none;
width: 40px;
font-size: 20px;
text-align: center;
margin-left: 5px;
}
<div id="con" class="console">
<button class="exit" onclick="hidecon()">X</button>
<span class="span" id="l1" style="width:50px"></span><br />
<span class="span" id="l2" style="width:50px"></span><br />
<span class="span" id="l3" style="width:50px"></span><br />
<span class="span" id="l4" style="width:50px"></span><br />
<span class="span" id="l5" style="width:50px"></span><br />
<span class="span" id="l6" style="width:50px"></span><br />
<span class="span" id="l7" style="width:50px"></span><br />
<span class="span" id="l8" style="width:50px"></span><br />
<span class="span" id="l9" style="width:50px"></span><br />
<span class="span" id="l10" style="width:50px"></span><br />
<span style="position: absolute; left: 0; bottom: 0;color:#66ff33;">C:\></span><input onclick="this.select()" id="code" class="inp"/>
<button style="border:none;position:absolute;background-color:black;bottom:0;right:114;color:#66ff33;border-radius: 5px;border: 1px solid white;" onclick="runcmd()">Send Command</button>
</div>
user,uname,passandpwrd?namorpwrd?