Answers for "get num and return is bunary"

0

how to convert to binary in javascript

function bin(num) {
    var binn = [];
    var c;
    while (num != 1) {
        c = Math.floor(num / 2);
        binn.unshift(num % 2);
        num = c;

    }
    binn.unshift(1)
    return binn
}
//returns list of binary nos. in order
Posted by: Guest on September-08-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language