I hereby claim:
- I am 03difoha on github.
- I am 03difoha (https://keybase.io/03difoha) on keybase.
- I have a public key ASDJ6mmDCc1Ym1dKEbm5WLoLicQcYgIlIVDMsMOxotxvUQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| function isSubset(list1, list2) { | |
| let list2 = [...new Set(list2)]; | |
| let confirmed = 0 | |
| for (var l of list2) { | |
| if (list1.includes(l)) { | |
| confirmed++ | |
| } | |
| } | |
| return confirmed == list2.length | |
| } |
| var ds = { | |
| totalCapacity: 1000, | |
| usedCapacity: 0, | |
| items: {}, | |
| updateCapacity: function(){ | |
| this.usedCapacity = Object.values(this.items).reduce((t, {weight}) => t + weight, 0) | |
| }, | |
| getItem: function (key) { | |
| return this.items[key] ? this.items[key] : -1 | |
| }, |
| function createArrayOfFunctions(y) { | |
| var arr = []; | |
| // fix: for (let i = 0; i < y; i++) { | |
| for (var i = 0; i < y; i++) { | |
| arr[i] = function (x) { | |
| return x + i; | |
| } | |
| // if we run arr[i] immediately inside the loop, we get the desired function. | |
| } | |
| // The problem is that the i inside each generated function all increment with each iteration. (scope leaking) |