I have the following code but when I try to build it, I get this error: events.js:174 throw er; // Unhandled 'error' event ^ GulpUglifyError: unable to minify JavaScript
This is my code:
$('.wp-block-button__link').click(function(e) {
e.preventDefault();
var href = $(this).attr('href');
var array = window.location.pathname.split('/').filter(word => word.length > 0);
window.location.href = href.trim('/') + '?brand=' + array[array.length - 1];
});
This line is problematic:
var array = window.location.pathname.split('/').filter(word => word.length > 0);
I think filter is the problem but i wonder if there's anything i can use instead of it?