Introduction to using functions as opposed to math.pow

  • 2020-03-30 03:39:30
  • OfStack


var a = [1,2,4,32,128];
 
var b = [];
 
for(var i=0;i<a.length;i++){
var index = Math.log(a[i])/Math.log(2);
b.push(index);
}
 
//b = [0,1,2,5,7];

Related articles: