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 616f5ff commit ca8a47cCopy full SHA for ca8a47c
3280-convert-date-to-binary.js
@@ -0,0 +1,31 @@
1
+/**
2
+ * @param {string} date
3
+ * @return {string}
4
+ */
5
+var convertDateToBinary = function(date) {
6
+ let temp = [], res =[]
7
+ for(let i of date){
8
+ if(i=='-'){
9
+ temp = dec_to_bin(temp.join(''))
10
+ res.push(...temp)
11
+ temp = []
12
+ res.push('-')
13
+ }
14
+ else temp.push(i)
15
16
17
18
+ return res.join('')
19
+};
20
+
21
+function dec_to_bin( a){
22
+ let b = +(a)
23
+ let res = []
24
+ while(b>0){
25
+ if(b&1)res.push('1')
26
+ else res.push('0')
27
+ b>>=1
28
29
+ res.reverse()
30
+ return res
31
+}
0 commit comments