Student // Web Developer // Photographer // Videographer // Events Technician

That first post

So a blog has always got to start somewhere and I thought I'd set the bar low, on the basis that it can only get better from here. Also, I'm hoping that this will get some responses to test out the new comments section.

And finally, the bit you've been waiting for, what the actual post is about - a binary to decimal converter. This was one of the first tasks we were set in our computing class and rather that model it with a flowchart this is how it would be done in Javascript:

var n = "11011010", total=0;
for(var i=0; i<n.length;i++) {
  var x=Number(n.substring(n.length-(i+1),n.length-i));

Where the variable n is your binary string. Here's a live demo:

Binary here:

Do you have a different/better of doing it? Leave a comment below, feel free to use CodePen

Tags: welcome computing code