It's best if you start with an example you can work out by hand. You can examine what happens and write code to accomplish it. Then you have a test case to use to give you an idea of whether it works or not. It's generally good to have several test cases.
As an example, consider convert 1010 to decimal.
Each position represents a power of 2.
1010 3210 - are the powers of 2 represented
So as a decimal number 1010 is 1*2^3 + 1*2^2 + 1*2^1 + 0*2^0 = 10