Javascript examples for Array Operation:Array Element
Using array inside recursive function
<html> <head></head> <body> <script> function factor(number, divisor, arr) { arr = arr || [];//from w ww. j ava2 s.co m if (divisor >= 1) { if (number % divisor === 0) { arr.push(divisor); return factor(number, divisor - 1, arr); } else { return factor(number, divisor - 1, arr); } } return arr; } console.log("factor of a number 36"); console.log(factor(36, 36)); </script> </body> </html>