This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Extend the String object with toBase64() and fromBase64() functions | |
| String.prototype.toBase64 = function () { | |
| const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; | |
| let result = ''; | |
| let i = 0; | |
| while (i < this.length) { | |
| let a = this.charCodeAt(i++) || 0; | |
| let b = this.charCodeAt(i++) || 0; | |
| let c = this.charCodeAt(i++) || 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const hammingWeight = v => { | |
| v = v - (v>>1 & 0x55555555); | |
| v = (v & 0x33333333) + (v>>2 & 0x33333333); | |
| return ((v + (v>>4) & 0xF0F0F0F) * 0x1010101) >> 24; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function SumBigNumbers (a, b) { | |
| var res = '', c = 0; | |
| a = a.split(''); | |
| b = b.split(''); | |
| while (a.length || b.length || c) { | |
| c += ~~a.pop() + ~~b.pop(); | |
| res = c % 10 + res; | |
| c = c > 9; | |
| } | |
| return res; |
NewerOlder