배열 선언하는 법
let coworkers = ["egoing", "leezche"];
배열은 0부터 시작
document.write(coworkers[0]);
document.write(coworkers[1]);
데이터 추가 방법
coworkers.push('duru');
coworkers.push('taeho');
배열의 길이 출력
document.write(coworkers.length);
<h1>Array</h1>
<h2>Syntax</h2>
<script>
let coworkers = ["egoing", "leezche"];
</script>
<h2>get</h2>
<script>
document.write(coworkers[0]);
document.write(coworkers[1]);
</script>
<h2>add</h2>
<script>
coworkers.push('duru');
coworkers.push('taeho');
</script>
<h2>count</h2>
<script>
document.write(coworkers.length);
</script>
반복문
<h1>Loop & Array</h1>
<script>
var coworkers = ['egoing','leezche','duru','taeho'];
</script>
<h2>Co workers</h2>
<ul>
<script>
var i = 0;
while(i < coworkers.length){
document.write('<li><a href="http://a.com/'+coworkers[i]+'">'+coworkers[i]+'</a></li>');
i = i + 1;
}
</script>
</ul>