Skip to content

์ฝ”ํ…Œ์šฉ snippetย #9

@dididy

Description

@dididy

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;
    })
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions