function kumite(arr) { return arr.filter((x, i, arr) => arr[i - 1] !== x && arr[i + 1] !== x); }
- function kumite(arr) {
return [];- return arr.filter((x, i, arr) => arr[i - 1] !== x && arr[i + 1] !== x);
- }
const expect = require("chai").expect; describe("Solution", function() { it("should get [1, 3, 4, 9, 5, 3] when given [1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3]", function() { const result = kumite([1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3]); expect(result).to.deep.equal([1, 3, 4, 9, 5, 3]); }); it("should get [] when given [1, 1, 2, 2, 2, 99, 99]", function() { const result = kumite([1, 1, 2, 2, 2, 99, 99]); expect(result).to.deep.equal([]); }); it("should get [] when given [6, 6, 6]", function() { const result = kumite([6, 6, 6]); expect(result).to.deep.equal([]); }); it("should get [1024] when given [1024]", function() { const result = kumite([1024]); expect(result).to.deep.equal([1024]); }); it("should get [] when given []", function() { const result = kumite([]); expect(result).to.deep.equal([]); }); it("should get [1, 2, 3, 4, 5, 6, 7] when given [1, 2, 3, 4, 5, 6, 7]", function() { const result = kumite([1, 2, 3, 4, 5, 6, 7]); expect(result).to.deep.equal([1, 2, 3, 4, 5, 6, 7]); }); it("should get [12, 3, 2, 8, 67, 98, 12, 23, 45, 98] when given [12, 4, 7, 7, 3, 2, 1, 1, 1, 8, 67, 98, 45, 45, 12, 23, 45, 98, 120, 120, 120]", function() { const result = kumite([12, 4, 7, 7, 3, 2, 1, 1, 1, 8, 67, 98, 45, 45, 12, 23, 45, 98, 120, 120, 120]); expect(result).to.deep.equal([12, 4, 3, 2, 8, 67, 98, 12, 23, 45, 98]); }); });
- const expect = require("chai").expect;
- describe("Solution", function() {
// it("should get [1, 3, 4, 9, 5, 3] when given [1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3]", function() {// const result = kumite([1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3]);// expect(result).to.deep.equal([1, 3, 4, 9, 5, 3]);// });- it("should get [1, 3, 4, 9, 5, 3] when given [1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3]", function() {
- const result = kumite([1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3]);
- expect(result).to.deep.equal([1, 3, 4, 9, 5, 3]);
- });
- it("should get [] when given [1, 1, 2, 2, 2, 99, 99]", function() {
- const result = kumite([1, 1, 2, 2, 2, 99, 99]);
- expect(result).to.deep.equal([]);
- });
- it("should get [] when given [6, 6, 6]", function() {
- const result = kumite([6, 6, 6]);
- expect(result).to.deep.equal([]);
- });
- it("should get [1024] when given [1024]", function() {
- const result = kumite([1024]);
- expect(result).to.deep.equal([1024]);
- });
- it("should get [] when given []", function() {
- const result = kumite([]);
- expect(result).to.deep.equal([]);
- });
- it("should get [1, 2, 3, 4, 5, 6, 7] when given [1, 2, 3, 4, 5, 6, 7]", function() {
- const result = kumite([1, 2, 3, 4, 5, 6, 7]);
- expect(result).to.deep.equal([1, 2, 3, 4, 5, 6, 7]);
- });
- it("should get [12, 3, 2, 8, 67, 98, 12, 23, 45, 98] when given [12, 4, 7, 7, 3, 2, 1, 1, 1, 8, 67, 98, 45, 45, 12, 23, 45, 98, 120, 120, 120]", function() {
- const result = kumite([12, 4, 7, 7, 3, 2, 1, 1, 1, 8, 67, 98, 45, 45, 12, 23, 45, 98, 120, 120, 120]);
- expect(result).to.deep.equal([12, 4, 3, 2, 8, 67, 98, 12, 23, 45, 98]);
- });
- });
const AbbreviateTwoWords = s => { const [a, b, ...c] = s.split(' '); return `${a[0]}.${b[0]}. ${c}` }
- const AbbreviateTwoWords = s => {
const [first, middle, ...rest] = s.split(' ')return `${first.slice(0,1)}.${middle.slice(0,1)}. ${rest}`- const [a, b, ...c] = s.split(' ');
- return `${a[0]}.${b[0]}. ${c}`
- }