Skip to content

Instantly share code, notes, and snippets.

Sourcegraph Cloud is the easiest way for organizations to get started with Sourcegraph.
└── Small-to-medium organizations can search across their code together on Sourcegraph Cloud.
└── Individual users can search across their private code on Sourcegraph Cloud.
└── Sourcegraph team members can search across their private code on Sourcegraph Cloud.
└── Individual users can search across their public code on Sourcegraph Cloud.
const card = { cost: [{count: 2, type: 'r'}, {count: 2, type: 'any'}, {count: 1, type: 'w/r', hybrid: true}] };
const availableMana = [{count: 4, type: 'r'}, {count: 2, type: 'w'}, {count: 1, type: 'w/r', hybrid: true}];
function hasEnoughMana(cost, availableMana) {
// If it requires more mana than is available in the first place
return cost.reduce((total, obj) => total + obj.count)) > cost.reduce((total, avail) => total + avail.count);
}
function hasRequiredMana(cost, availableMana) {
// Return if the available mana matches the required mana