<h1>配列を作る</h1>
MyArray = new Array('X','Y','Z');<br>
<br>
a = MyArray[0];<br>
b = MyArray[1];<br>
c = MyArray[2];<br>
<br>
document.write(a);<br>
document.write(b);<br>
document.write(c);<br>
↓<br>
<script>
MyArray = new Array('X','Y','Z');
a = MyArray[0];
b = MyArray[1];
c = MyArray[2];
document.write(a);
document.write(b);
document.write(c);
</script>
<h1>関数</h1>
anser = add(1,2);<br>
document.write(anser);<br>
<br>
function add(x, y) {<br>
z = x + y;<br>
return z;<br>
}<br>
↓実行結果<br>
<script>
anser = add(1,2);
document.write(anser);
function add(x, y) {
z = x + y;
return z;
}
</script>
<h1>条件分岐</h1>
<pre>
a = 1;
ret = checker(a);
document.write(ret);
function checker(v){
if(v==1){
//条件一致した場合実行される
return true;
}else{
//条件に合わない場合実行される
return false;
}
}
</pre>
↓実行結果<br>
<script>
a = 1;
ret = checker(a);
document.write(ret);
function checker(v){
if(v==1){
//条件一致した場合実行される
return true;
}else{
//条件に合わない場合実行される
return false;
}
}
</script>