You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							24 lines
						
					
					
						
							480 B
						
					
					
				
			
		
		
	
	
							24 lines
						
					
					
						
							480 B
						
					
					
				| /**
 | |
|  * Merges two arrays.
 | |
|  * @param  {*} a
 | |
|  * @param  {*} b
 | |
|  * @return {*}
 | |
|  */
 | |
| export default function mergeArrays(a, b) {
 | |
| 	const merged = a.slice()
 | |
| 
 | |
| 	for (const element of b) {
 | |
| 		if (a.indexOf(element) < 0) {
 | |
| 			merged.push(element)
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	return merged.sort((a, b) => a - b)
 | |
| 
 | |
| 	// ES6 version, requires Set polyfill.
 | |
| 	// let merged = new Set(a)
 | |
| 	// for (const element of b) {
 | |
| 	// 	merged.add(i)
 | |
| 	// }
 | |
| 	// return Array.from(merged).sort((a, b) => a - b)
 | |
| } |