549 const mbed = new Discord.MessageEmbed()
550 .setColor(6765239)
551 .setTitle("Spell Check");
552 items.some(({ fragment, suggestions }) => {553 let addition = `~~${fragment}~~ → **${suggestions.join("**, **") || "No suggestions"} **\n`;
554 if (desc.length + addition.length > 2000) {
555 mbed.setFooter("This spellcheck has been shortened.");
Array
has several methods for filtering, mapping, and folding.
If we forget to write return statement in a callback of those, it's probably a mistake.
If you don't want to use a return
or don't need the returned results, consider using .forEach
instead.
const indexMap = myArray.reduce(function(memo, item, index) {
memo[item] = index;
}, {});
const foo = Array.from(nodes, function(node) {
if (node.tagName === "DIV") {
return true;
}
});
const bar = foo.filter(function(x) {
if (x) {
return true;
} else {
return;
}
});
const indexMap = myArray.reduce(function(memo, item, index) {
memo[item] = index;
return memo;
}, {});
const foo = Array.from(nodes, function(node) {
if (node.tagName === "DIV") {
return true;
}
return false;
});
const bar = foo.map(node => node.getAttribute("id"));