Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

reverse array with recursion javascript

// reverse array with recursion javascript
let data = [5, 12, 65, 89, 0, 100]
let temp
function customReverse(data, start, end) {
	if (start <= end) {
		temp = data[start]
		data[start] = data[end]
		data[end] = temp
		customReverse(data, start + 1, end - 1)
    return data;
  }
}
console.log(customReverse(data, 0, data.length - 1))
 
PREVIOUS NEXT
Tagged: #reverse #array #recursion #javascript
ADD COMMENT
Topic
Name
4+4 =