学習目的で、ローカルストレージで機能すると思われる簡単なメッセージングプログラムを作成しています。2次元配列に関するもう1つの質問は、コメントにあります。
<!DOCTYPE HTML>
<html>
<head>
<title>waGwan?</title>
<meta charset="utf-8"/>
<link rel=stylesheet href=comm.css></link>
</head>
<body>
<section>
<p>enter or create passcode: <input type=text id=passcode></p>
<input type=button id="button" value="send">
</section>
<section id="log"></section>
<script type="text/javascript">
//initializing my passcode. Pass is a two dimensional array that holds passcodes and arrays of corresponding message logs; how can I instantiate my passcode without nil but maintain pass as a two dimensional array, just not include pass?
var pass=[mypasscode,nil];
document.getElementById("button").onclick=checkPass;
function checkPass(){
for(i=0;i<pass.length;i++){
//exits if passcode exists
if(document.getElementById("passcode").value==pass[i]){
break;
}
//if passcode doesn't equal last existing passcode the passcode and a new array (that stores the message log) is added to the pass array
else if(document.getElementById("passcode").value!==pass[pass.length-1]){
pass.push(document.getElementById("passcode").value,[We can chat here.]);
}
}
document.write("x");
}
</script>
</body>
</html>