Skip to content

Instantly share code, notes, and snippets.

@dstyle0210
Created July 18, 2016 00:59
Show Gist options
  • Select an option

  • Save dstyle0210/e4d785f3319355c3596b44d0df7cd1c1 to your computer and use it in GitHub Desktop.

Select an option

Save dstyle0210/e4d785f3319355c3596b44d0df7cd1c1 to your computer and use it in GitHub Desktop.
[코딩도장] 사이냅소프트 면접문제
// 코딩도장 공부 : 사이냅소프트 면접문제
// 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;
var uniq = data.reduce(function(a,b){
if (a.indexOf(b) < 0 ) a.push(b);
return a;
},[]);
var sort = uniq.sort();
console.log(lee+","+kim+","+leejy);
console.log(uniq);
console.log(sort);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment