//0%3 = 0;
//1%3 = 1;
//2%3 = 2;
//3%3 = 0;
//4%3 = 1;
//5%3 = 2;
//6%3 = 0;
//7%3 = 1;
//8%3 = 2;
//9%3 = 0;
var textElement = document.getElementById('txt');
var words = ["에드게이", "피이니티 왕", "에이디오바 우트라"];
function TypeWriter(txtElement, words){
this.textElement = texElement;
this.words = words;
this.txt ="";
this,wordIndex = 0;
this,isDeleting =false;
}
typeWriter.prototype.type = function(){
var current = this.wordIndex %this.words.length;
var fulltxt = this.words[current];
if(this.isEdleting{
this.txt = fulltxt.substing(0,this.txt.length-1);
}else{
this.txt = fulltxt.substing(0,this.txt.length+1);
}
this.txtElement.txtContent = this.txt;
if(!this.isDeleing && this.txt===fulltxt){
this.isDeleting = true;
} else if(this.isDeleting && this.txt===""){
this.idDeleting = false;
this.wordIndex++;
}
var that = this; //(2)..(1)을해결위해
setTomeout(function(){
//this.type()//중첩디스 윈도우(1)
that.type(); // (3)
}, 1000);
nuw TypeWriter(txtElement, words);
//나라면 함수 만들것도 없이 객체의 인텍스만큼 반복시키면서 0부터 1~인덱스까지 출력시키는 방법을 택할것 같은데 장단점이 있겠죠