Skip to content
Advertisement

Is there a way to make this code shorter? (reaction collector)

JavaScript

I tried to make one filter for both collectors but still have to type this (x,y,z) => filter(x,y,z,'⏪')

JavaScript

Advertisement

Answer

You can make a higher-order function, one that takes in the character you’re looking for and returns a function that takes three arguments (reaction, user, and c, corresponding to your current (x, y, x) =>) and returns the appropriate filter operation.

Also, it doesn’t look like c (same as z) is being used at all in any code here, so feel free to remove it from the argument list.

JavaScript
Advertisement