Created
June 29, 2022 14:19
-
-
Save krrskl/34508c281655087974526f05905b4b66 to your computer and use it in GitHub Desktop.
This code base is a test make to midudev by recruiter from arc.dev
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import assert from 'node:assert'; | |
const firstLeftArray = [ | |
{ id: 0, name: 'Miguel' }, | |
{ id: 1, name: 'Justin' }, | |
{ id: 3, name: 'Test' }, | |
]; | |
const firstRightArray = [ | |
{ id: 0, email: '[email protected]' }, | |
{ id: 2, email: '[email protected]' }, | |
{ id: 3, email: '[email protected]' }, | |
]; | |
const secondLeftArray = [ | |
{ id: 0, name: 'Miguel' }, | |
{ id: 1, name: 'Justin' }, | |
]; | |
const secondRightArray = [ | |
{ id: 0, email: '[email protected]' }, | |
{ id: 2, email: '[email protected]' }, | |
]; | |
const thirdLeftArray = [ | |
{ id: 0, name: 'Miguel', email: '[email protected]' }, | |
{ id: 1, name: 'Justin' }, | |
{ id: 3, name: 'Test', email: '[email protected]' }, | |
]; | |
const thirdRightArray = [ | |
{ id: 0, lastName: 'Duran' }, | |
{ id: 2, email: '[email protected]', lastName: 'Faker' }, | |
{ id: 3, email: '[email protected]', lastName: 'Faker2' }, | |
]; | |
const firstExpectedOutput = [ | |
{ id: 0, name: 'Miguel', email: '[email protected]' }, | |
{ id: 3, name: 'Test', email: '[email protected]' }, | |
]; | |
const secondExpectedOutput = [ | |
{ id: 0, name: 'Miguel', email: '[email protected]' }, | |
]; | |
const thirdExpectedOutput = [ | |
{ id: 3, name: 'Test', email: '[email protected]', lastName: 'Faker2' }, | |
]; | |
function innerJoin(leftArray, rightArray, key) { | |
// do the magic here | |
} | |
const firstResult = innerJoin(firstLeftArray, firstRightArray, 'id'); | |
const secondResult = innerJoin(secondLeftArray, secondRightArray, 'id'); | |
const thirdResult = innerJoin(thirdLeftArray, thirdRightArray, 'email'); | |
assert.deepStrictEqual( | |
firstExpectedOutput, | |
firstResult, | |
'❌ First expected output not match' | |
); | |
console.log('✅ First expected output match'); | |
assert.deepStrictEqual( | |
secondExpectedOutput, | |
secondResult, | |
'❌ Second expected output not match' | |
); | |
console.log('✅ Second expected output match'); | |
assert.deepStrictEqual( | |
thirdExpectedOutput, | |
thirdResult, | |
'❌ Third expected output not match' | |
); | |
console.log('✅ Third expected output match'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Live on Twich: https://www.twitch.tv/videos/1512033141