We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5bfd552 commit c92e811Copy full SHA for c92e811
jungmyunggi/Convert Date to Binary.js
@@ -0,0 +1,20 @@
1
+/**
2
+ * @param {string} date
3
+ * @return {string}
4
+ */
5
+
6
+function convertBinary(num){
7
+ const stack = [];
8
+ while(num > 0){
9
+ stack.push(num%2);
10
+ num = Math.floor(num/2);
11
+ }
12
+ return stack.reverse().join("");
13
+}
14
+var convertDateToBinary = function(date) {
15
+ const [year, month, day] = date.split("-");
16
+ const y = convertBinary(Number(year))
17
+ const m = convertBinary(Number(month))
18
+ const d = convertBinary(Number(day));
19
+ return `${y}-${m}-${d}`
20
+};
0 commit comments