app.get('/binary-to-number/:binary', (req,res) => {
var binary = req.params.binary
var power = binary.length-1
var count = 0
for (var i = 0; i < binary.length; i++) {
number = parseInt(binary.charAt(i),10)
number = number * Math.pow(2,power)
count = number + count
power = power - 1
}
res.json({"decimal" : count})
})
app.get('/number-to-binary/:number', (req,res) => {
var number = req.params.number
var quotient = number
var remainder = number
var binaryString = ""
while(quotient != 0){
remainder = quotient % 2
quotient = Math.floor(quotient/2)
bit = remainder
binaryString = bit + binaryString
}
res.json({"binary" : binaryString})
})