순서도를 모두 합치려면 아주 큰 종이가 필요하겠지만, 프로그램을 합치는 건 매우 쉽습니다.
다음 프로그램에는
console
.
log
를 호출하는 부분이 들어있습니다. 이 함수는 토마스가 게임을
어떻게 진행하고 있는지 알아보려고 넣은 겁니다. 지금 당장
console
.
log
에 대해 이해할 필요
는 없습니다. 책을 진행하면서 고급 테크닉을 배우다 보면 자연히 알게 됩니다.
토마스가 지금 몇 판째 게임을 하는지 알아보는
round
변수도 추가했습니다.
//
m
이상
n
이하의 무작위 정수를 반환합니다.
function
rand
(
m
,
n
) {
return
m
+
Math
.
floor
((
n
-
m
+
1
)*
Math
.
random
());
}
122
러닝 자바스크립트
// 크라운 앤 앵커 게임의 여섯 그림 중 하나에 해당하는 문자열을 무작위로 반환합니다.
function
randFace
() {
return
["
crown ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.