0
Can anyone help me with the code ?
I need to convert binary number to decimal without using built in functions, so I generated this code but Smith in the syntax or the logic is wrong. var bin=[]; for(var i=0;i<bin.length;i++){ var a=Math.pow(bin[i],2); document.write(a); document.write("<br>"); } var a=[]; var dec; function b2d(a){ for(var j=a.length-1;j<a.length;j++){ dec+=j } return dec; } alert(b2d(a));
1 Answer
0
Both the bin array and the a array have a length of 0 when you are trying to do a comparison in your loops.