[자바스크립트] 코드아카데미 문제풀이 Build "Rock, Paper, Scissors" (3/9)
Computer Choice: Part 1
Awesome! We now need the computer to make a choice. The game is only going to be fun if the computer chooses randomly. Luckily JavaScript has something that can help with this.
If we declare a variable and make it equal to Math.random()
, that variable will equal a number between 0 and 1.
var 변수 computerChoice에 랜덤 값을 대입시킵니다.
var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
console.log(computerChoice);
var computerChoice = Math.random();
console.log(computerChoice);
위와 같이 입력하면 통과합니다.
반응형