A tiny coding challenge
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
// Given | |
let array = [0, 1, 2, 3, 4, 5, 6]; | |
let elementsToMove = [2, 3, 4]; | |
// Tasks | |
// 1) | |
// Given an arbitrary new index, re order the array so that | |
// elementsToMove is moved to the correct position | |
let moveElementsAfterIndex = 5; | |
let expectedResult1 = [0, 1, 5, 2, 3, 4, 6]; | |
let moveElementsBeforeIndex = 0; | |
let extectedResult2 = [2, 3, 4, 0, 1, 5, 6]; | |
// 2) | |
// The same as 1) but your array and elementsToMove should be | |
// something like [ {id: 0, name: 'zero' },{id: 1, name: 'one'}, {id: 2, name: 'two'}, ...] | |
// 3) | |
// How could a solution look like that can solves 1) and 2) at the same time? Is it achievable? Is it prudent? Why? Why not? | |
// 4) | |
// should you be familiar with testing, indicate how you would write a tests for your solution(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment