분류 전체보기(75)
-
[Node.js] Node.js 설치
https://nodejs.org/ Node.js Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. nodejs.org current로 다운 받음 LTS : 장기적으로 안정된 지원 보장 Current : 최신 버전 / 최신 기능 제공, 업데이트가 발생하는 버전으로 안정적이지 않을 수 있음 다운 받은 후 cmd 창에서 Node.js와 npm의 버전을 출력해 정상적으로 설치 되었는지 확인
2022.05.27 -
[js] 버튼 클릭 시 숫자 증가 증감
0 + - const $counter = document.getElementById('counter'); const $increase = document.getElementById('increase'); const $decrease = document.getElementById('decrease'); let num = 0; const render = function() {$counter.innerHTML = num;}; $increase.onclick = function(){ num++; console.log('increase 버튼클릭', num); render(); }; $decrease.onclick = function(){ num--; console.log('decrease 버튼 클릭', num);..
2022.05.27 -
[js] 가위바위보 맞히기 (Math.random)
document.write("컴퓨터 가위, 바위 , 보 맞히기"); var game = prompt("가위, 바위, 보 중에 선택하세요" , "가위"); var gameNum; switch (game){ case "가위": gameNum = 1; break; case "바위": gameNum = 2; break; case "보": gameNum = 3; break; default:alert("잘못 입력했다"); location.reload(); } var com = Math.ceil(Math.random()*3) if(gameNum == com){ document.write("정답"); }else{ document.write("땡 "); }
2022.05.26 -
[js]난수 Math.random
Math.random() //0~1 사이의 난수를 반환 Math.random()*10; //0부터 10까지 실수로 난수를 반환 >> 정수로만 난수를 반환하려면 floor()를 사용해야 함 Math.floor(Math.random()*11); //0부터 10까지 난수를 발생하여 소수점 값을 제거 floor는 값을 내리기 때문에 하나 더 많게 난수를 발생하여 원하는 구간 정수의 값 구하기 Math.floor(Math.random()*(최댓값 - 최솟값 +1))+최솟값; 120~150 사이의 난수를 정수로만 발생하기 Math.floor(Math.random()*31); //0부터 30까지 정수로 난수를 발생 Math.floor(Math.random()*31)+120; //120부터 150까지 정수로 난수를 발생
2022.05.26 -
[js] D-DAY 구하기 (Date)
보호되어 있는 글입니다.
2022.05.26 -
[js] Date 객체 - 날짜 정보
보호되어 있는 글입니다.
2022.05.26