JS 100제 문제 12 게임 캐릭터 클래스 만들기

이민정·2021년 4월 5일
0

JS100제

목록 보기
6/66

<풀이 코드>

class Wizard{
	constructor(x,y,z){ //constructor은 생성자 함수 그 자체를 가리킴, constructor 대신 Wizard 써도 됨
		this.health = x;
		this.mana = y;
		this.armor = z;
	}
	attack(){
		console.log("파이어볼");	
	}
};

const x = new Wizard(545, 210, 10);
console.log(x.health, x.mana, x.armor);
x.attack();
profile
공부하자~!

0개의 댓글