프로그래머스 - 같은숫자는싫어
February 10, 2020
같은숫자는싫어
const notLike = arr => {
const mapList = [];
for (let i = 0; i < arr.length; i++) {
if (arr[i] !== arr[i + 1]) {
mapList.push(arr[i]);
}
}
return mapList;
};
test("같은숫자는 싫어요", () => {
expect(notLike([1, 1, 3, 3, 0, 1, 1])).toEqual([1, 3, 0, 1]);
});