js lang solution №1 update
This commit is contained in:
parent
2a3ed164a3
commit
2feb7c18e9
1 changed files with 3 additions and 4 deletions
|
|
@ -1,9 +1,8 @@
|
|||
function tenToBin(x) {
|
||||
const l = [];
|
||||
let i = x;
|
||||
while (i !== 0) {
|
||||
l.push(i % 2);
|
||||
i = Math.trunc(i / 2);
|
||||
while (x !== 0) {
|
||||
l.push(x % 2);
|
||||
x = Math.trunc(x / 2);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue