-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathconcat.js
35 lines (32 loc) · 1.17 KB
/
concat.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Given two arrays, returns a new array that is a concatenation of the
* two given arrays.
*
* "Concatenation" means the two arrays are joined or glued together, end-to-end.
*
* JavaScript array's have a built-in concatenation method. Don't use it!
* The goal is to better understand how concatenation works, not navigate
* the JavaScript documentation.
*
* See https://en.wikipedia.org/wiki/Concatenation
*
* @example
* concat([1, 2, 3], [4, 5, 6]); // => [1, 2, 3, 4, 5, 6]
* concat([-10, undefined], [true, 'waffles']); // => [-10, undefined, true, 'waffles']
* concat([], []); // => []
* concat([20, 104], []); // => [20, 104]
* concat([], ['hello', 'world']); // => ['hello', 'world']
*
* @param {object[]} leftArray - The left array to concatenate
* @param {object[]} rightArray - The right array to concatenate
* @returns {object[]} The concatenation of the two given arrays
*/
function concat(leftArray, rightArray) {
// This is your job. :)
}
if (require.main === module) {
console.log('Running sanity checks for concat:');
// Add your own sanity checks here.
// How else will you be sure your code does what you think it does?
}
module.exports = concat;