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) {
|
function tenToBin(x) {
|
||||||
const l = [];
|
const l = [];
|
||||||
let i = x;
|
while (x !== 0) {
|
||||||
while (i !== 0) {
|
l.push(x % 2);
|
||||||
l.push(i % 2);
|
x = Math.trunc(x / 2);
|
||||||
i = Math.trunc(i / 2);
|
|
||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue