题解 | #二进制转换#
二进制转换
http://www.nowcoder.com/practice/7b74386695cc48349af37196f45e62a8
function convertToBinary(num) {
const n = num.toString(2)
return n.length < 8 ? new Array(8-n.length).fill(0).join('') + n : n
}
二进制转换
http://www.nowcoder.com/practice/7b74386695cc48349af37196f45e62a8
function convertToBinary(num) {
const n = num.toString(2)
return n.length < 8 ? new Array(8-n.length).fill(0).join('') + n : n
}
相关推荐