I'm stuck in a programming logic problem, where you need to create a JavaScript function that takes a decimal and converts it to binary.
I'm stuck in a programming logic problem, where you need to create a JavaScript function that takes a decimal and converts it to binary.
DEC2BIN
converts a decimal number to a binary number
function dec2bin(dec){
return (dec >>> 0).toString(2);
}
console.log(dec2bin(256));
console.log(dec2bin(1024));
Resultado Formula
1010 = DEC2BIN(10)
01010 = DEC2BIN(10, 5)
1111100000 = DEC2BIN(-32)
strong>