This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| try{ | |
| fs.mkdirSync('생성할폴더명(경로로 지정도 가능)'); | |
| }catch(e){ | |
| if ( e.code != 'EEXIST' ) throw e; // 존재할경우 패스처리함. | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(function(){ | |
| var promise1 = new Promise(function (resolve, reject) { | |
| $.getJSON("ajax경로1",function(result) { | |
| // 해결됨 | |
| console.log("첫번째 Promise 완료"); | |
| resolve(result); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| node 에서 request을 이용해서, http을 통한 json 가져오기. | |
| */ | |
| var fs = require('fs'); | |
| var _ = require("underscore"); | |
| var request = require("request"); | |
| var url = "가져올 JSON 경로" | |
| request({ | |
| url: url, | |
| json: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 코딩도장 공부 : 사이냅소프트 면접문제 | |
| // http://codingdojang.com/scode/410 | |
| /* 김씨와 이씨는 각각 몇 명 인가요? | |
| "이재영"이란 이름이 몇 번 반복되나요? | |
| 중복을 제거한 이름을 출력하세요. | |
| 중복을 제거한 이름을 오름차순으로 정렬하여 출력하세요. */ | |
| var data = ("이유덕,이재영,권종표,이재영,박민호,강상희,이재영,김지완,최승혁,이성연,박영서,박민호,전경헌,송정환,김재성,이유덕,전경헌").split(","); | |
| var lee = data.filter(function(name){return ((/^이/).test(name))}).length; | |
| var kim = data.filter(function(name){return ((/^김/).test(name))}).length; | |
| var leejy = data.filter(function(name){return ((/^이재영/).test(name))}).length; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 코딩도장 공부 : 문자열 압축하기 | |
| // http://codingdojang.com/scode/465 | |
| var data = "aaabbcccccca"; | |
| var str = ""; | |
| var num = 1; | |
| var target = ""; | |
| data.split("").forEach(function(item){ | |
| if(target!=item){ | |
| str += (target!="") ? target+""+num : ""; | |
| target = item; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 코딩도장 공부 | |
| // http://codingdojang.com/scode/266 | |
| // 임시 데이터 생성. | |
| var col = 8; | |
| var row = 4; | |
| var data = (function(){ | |
| var arr = []; | |
| for(i=0;i<row;i++){ | |
| arr[i] = new Array(col); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 코딩도장 공부 | |
| // http://codingdojang.com/scode/408 | |
| // 임시 데이터 생성. | |
| var data = (function(){ | |
| var arr = []; | |
| for(i=0;i<20;i++){ | |
| arr[i] = Math.floor(Math.random()*500); | |
| }; | |
| // 데이터 정렬 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 코딩도장 공부 | |
| // http://codingdojang.com/scode/406 | |
| var m = Math.floor(Math.random()*100); // 총건수 | |
| var n = Math.floor(Math.random()*10)+1; // 한페이지에 보여줄 게시물수 (n은 1보다 크거나 같다) | |
| var paging = (0<m) ? Math.floor(m/n) : 0; // 총건수가 0개면, 리턴도 0개. | |
| paging = (paging!=0 && m%n!=0) ? paging + 1 : paging; | |
| console.log(m+","+n+","+paging); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 코딩도장 공부 | |
| // http://codingdojang.com/scode/393 | |
| var samText = ""; | |
| for(i=1;i<10000;i++){ | |
| samText += i+""; | |
| }; | |
| var total = (samText.match(/8/g)).length; | |
| console.log(total); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 코딩도장 공부 | |
| // http://codingdojang.com/scode/365 | |
| var max = 5000; | |
| // 숫자들의 합 구하기. | |
| var total = 0; | |
| (function(){ | |
| for(i=0;i<max;i++){ | |
| total += i; | |
| }; |