Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

코테용 snippet #9

Open
dididy opened this issue Mar 20, 2021 · 0 comments
Open

코테용 snippet #9

dididy opened this issue Mar 20, 2021 · 0 comments
Assignees

Comments

@dididy
Copy link
Member

dididy commented Mar 20, 2021

key 기준으로 object 정렬하기

const dict = {
  'b': 100,
  'a': 200,
  'b': 300,
};

const orderedAnswer = Object.keys(dictScore)
  .sort()
  .reduce((obj, key) => {
    obj[key] = dictScore[key];
    return obj;
  }, {});

배열에 같은 숫자 카운트 Map, Object 만들기

https://dongmin-jang.medium.com/javascript-15%EA%B0%80%EC%A7%80-%EC%9C%A0%EC%9A%A9%ED%95%9C-map-reduce-filter-bfbc74f0debd

배열 빼기

const minusArray = (completeArray, targetArray) => {
    return targetArray.map(eachIndex => {
        const resultOfMinusArray = [];
        completeArray.forEach((each) => {
            if (!eachIndex.includes(each)) {
                resultOfMinusArray.push(each);
            }
        })
        return resultOfMinusArray;
    })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant