https://www.npmjs.com/package/prompt-sync
사용자 입력받기 코드 복사후 터미널에 붙여넣기하고 엔터
https://hianna.tistory.com/454
const prompt = require('prompt-sync')();
//1단계 홀짝 숫자 만들기
//parseInt() 소수를 정수로
const num = parseInt((Math.random() * 100) % 2)
console.log(num)
//2단계 사용자 입력
const answer = readlineSync("ODD O? EVEN E?")
//삼항연산자
const condition1 = num === 0 && answer === "E"
const condition2 = num === 1 && answer === "O"
//num이 0이고 answer가 E || num이 1이고 answer가 O
const result = condition1 || condition2 ?"정답":"오답"
console.log(`최종결과는 ${result}`)
'자바스크립트' 카테고리의 다른 글
자바스크립트 : 알아야 될 용어정리 (0) | 2021.11.13 |
---|---|
Undefined 이해하기 (0) | 2021.11.11 |
제어문 if / switch / 삼항 조건연산자 (0) | 2021.11.08 |
let과 var의 차이 : 호이스팅 (0) | 2021.11.08 |
단위 변환 문제 (0) | 2021.11.08 |