Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to split an array into two javascript

function cleanUpArray(arr) {
	let intArray = arr.map(x => parseInt(x))
	let evenArray = []
	intArray.map(x => {
		if(x % 2 === 0){
			evenArray.push(x)
		}
	})
		let oddArray = []
	intArray.map(x => {
		if(x % 2 !== 0){
			oddArray.push(x)
		}
	})
	return [evenArray, oddArray]
}
 
PREVIOUS NEXT
Tagged: #split #array #javascript
ADD COMMENT
Topic
Name
8+5 =