I just completed a Rosetta Code challenge (ABC problem) which passes all the tests when I run it in VS Code but fails all the tests in online editor. Here’s the code I used:
function canMakeWord(word) {
const availableBlocks = new Set(['BO','XK','DQ','CP','NA','GT','RE','TG','QD','FS','JW','HU','VI','AN','OB','ER','SF','LY','PC','ZM'])
for (ch of word.toUpperCase()) {
const block = [...availableBlocks].find(block => block.includes(ch));
if (!block) return false; // Letter cannot be formed
availableBlocks.delete(block); // Remove the used block
}
return true; // All letters can be formed with available blocks
}
When I changed to use older style coding of loops, sets and searches, it passed all the tests.
Is it possible to configure Javascript to use all the modern features?