+ 2
JavaScript : Decimal To Binary
Decimal <> Binary https://code.sololearn.com/WyhNLoNv9gIf/?ref=app
1 Réponse
+ 1
try this way
function binaryConvert() {
var num = x;
if (num != Math.floor(num)) {
console.log("Please enter a number");
} else if (num < 0) {
console.log("Please enter a positive number");
} else {
var binary = parseInt(num, 10);
console.log(binary.toString(2));
}
}
binaryConvert();