I hereby claim:
- I am daubattu on github.
- I am daubattu (https://keybase.io/daubattu) on keybase.
- I have a public key ASBTpgg7GynCVrzIEtnznswkwvUA31GHj-Om_4ZCGZatrwo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| function getTotalX(a, b) { | |
| // Write your code here | |
| let result = 0; | |
| let index = 1; | |
| let cloneA = a.splice(1, a.length); // clone new array of a but not a[0] | |
| while(a[0] * index <= b[0]) { | |
| if( | |
| cloneA.every(item => (a[0] * index) % item === 0) | |
| && | |
| b.every(item => item % (a[0] * index) === 0) |
| function breakingRecords(scores) { | |
| let best = 0; | |
| let worst = 0; | |
| let bestScore = scores[0]; | |
| let worstScore = scores[0]; | |
| const lengthOfData = scores.length; | |
| for(let i = 1; i < scores.length; i++) { | |
| if (scores[i] > bestScore) { | |
| bestScore = scores[i]; | |
| best++; |
| function birthday(s, d, m) { | |
| let result = 0; | |
| for(let i = 0; i < s.length - (m - 1); i++) { | |
| if (s.slice(i, i + m).reduce((r, v) => r + v, 0) === d) { | |
| result++; | |
| } | |
| } | |
| return result; | |
| } |
| function divisibleSumPairs(n, k, ar) { | |
| let result = 0; | |
| for(let i = 0; i < n - 1; i++) { | |
| result += ar.slice(i + 1, n).filter((item, index) => { | |
| if ((item + ar[i]) % k === 0) { | |
| return item; | |
| } | |
| }).length; | |
| } | |
| return result; |
| function bonAppetit(bill, k, b) { | |
| const sum = bill.reduce((r, v) => r + v, 0); | |
| const result = (sum - bill[k])/2; | |
| if (b - result === 0) console.log('Bon Appetit'); | |
| else console.log(b - result); | |
| } |
| function pageCount(n, p) { | |
| /* | |
| * Write your code here. | |
| */ | |
| const pageFromStart = Math.floor(p/2); | |
| const pageFromEnd = Math.ceil(((n % 2 !== 0 ? n - 1 : n) - p)/2); | |
| return Math.min(pageFromStart, pageFromEnd); | |
| } |
| function getMoneySpent(keyboards, drives, b) { | |
| /* | |
| * Write your code here. | |
| */ | |
| let max = -1; | |
| for(let i = 0; i < keyboards.length; i++) { | |
| const keyboardPrice = keyboards[i]; | |
| for(let j = 0; j < drives.length; j++) { | |
| const drivePrice = drives[j]; |
| const users = [ | |
| { | |
| id: 1, | |
| name: 'Nguyễn Hưng Khánh', | |
| girl_friend: { | |
| name: 'Nguyễn Thị Khánh', | |
| address: 'Hà Nội' | |
| } | |
| }, | |
| { |
| // users[0] | |
| console.log(users[0].girl_friend.name) | |
| // users[1] | |
| if (users[1].girl_friend) { | |
| console.log(users[1].girl_friend.name) | |
| } else { | |
| console.log('Lêu lêu. Thằng này ê sắc ế') | |
| } |