JavaScript function that produces an array that multiplies x number of times based on previous integer -


so i've got function , needs produce array multiplies x number of times based on previous integer. function take 2 integers arguments so:

function powerof(x, n) {  } 

for example: powerof(3, 4) produce [3, 9, 81, 6561].

can point me in right direction?

this function you've been looking for:

function test(a,b){     // declarin array result     var res = [a];      // going through array , adding multiplied numbers     for(var = 1; i<b;i++){         res[i] = res[i-1]*res[i-1];     }      // returning result     return res; }  console.log(test(3,4)); // result : [3, 9, 81, 6561] 

first decalare array server result.first entry in array first number (a). rest of array (b-1), need multiply last entry in array self.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -