Skip to content
This repository was archived by the owner on Dec 24, 2024. It is now read-only.

Challenge instructions - Index#5

Open
joaobibiano wants to merge 1 commit intomasterfrom
test-queue-message-array
Open

Challenge instructions - Index#5
joaobibiano wants to merge 1 commit intomasterfrom
test-queue-message-array

Conversation

@joaobibiano
Copy link

// ...................... AUTHOR : JOÃO VICTOR BIBIANO PINHEIRO ...................... //
// ...................... NUMBER: (18) 99674-1075               ...................... //
// ...................... PLACE: MARÍLIA-SP                     ...................... //

const processQueue = (arr1, arr2) => {
  return arr1.filter(el => arr2.includes(el)).sort((a, b) => a - b);
};

const getPayload = () => {
  return Array([3, 5, 6, 1, 2, 16], [16, 6, 91, 1, 4, 3, 123, 1, 1]);
};

const start = () => {
  const data = getPayload();

  let result = processQueue(data[0], data[1]);

  console.log(result);
};

module.exports = {
  processQueue,
  getPayload,
  start
};

//Starting only to show it's working
start();

@joaobibiano
Copy link
Author

const { getPayload, processQueue } = require('../src/index');

test('Get data from payload', () => {
  expect(getPayload()).toStrictEqual(
    Array([3, 5, 6, 1, 2, 16], [16, 6, 91, 1, 4, 3, 123, 1, 1])
  );
});

test('Checking logic', () => {
  let data = getPayload();
  expect(processQueue(data[0], data[1])).toStrictEqual(Array(1, 3, 6, 16));
});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants