본문 바로가기
Code Combat

키트가드 던전 - 1. Dangerous Steps (난이도 1)

by qdwe 2021. 12. 28.

Dangerous Steps (위험한 발걸음)

- 오우거를 물리치기 위하여 String 을 사용하시오.

스킬: 기본 구문

https://codecombat.com/play/level/dangerous-steps? 

 

CodeCombat - Coding games to learn Python and JavaScript

Learn typed code through a programming game. Learn Python, JavaScript, and HTML as you solve puzzles and learn to make your own coding games and websites.

codecombat.com

 

목표:

모든 오우거를 물리쳐라.

- 이름을 지정하여 오우거를 물리치기 위하여 String 을 사용해야 한다.

 

 

시작화면:

시작코드:

개념설명:

String 은 문자열이라는 뜻의 영어이다.

"Sog"

"Gos" 

"안녕하세요. 만나서 반가워요."

위와 같이 따옴표 안에 들어오는 글자는 모두 하나의 문자열이다.

만약 문자열을 저장하고 싶다면 아래와 같이 쓰면 된다.

myenemy = "Sog"

 

Sog 라는 오우거 한마리를 물리치고자 하는 경우 아래와 같이 쓰면 된다. 

myenemy = "Sog"
hero.attack(myenemy)
hero.attack(myenemy)

 

아빠의 말:

야 니가 이걸 진짜로 몰랐다고?