Пример:
if (/entertainments/.test(window.location.href)) {
//code here
}
if (/suggestions/.test(window.location.href)) {
//same code here
}
я пытался
if (/entertainments/||/suggestions/.test(window.location.href))



![Безумие обратных вызовов в javascript [JS]](https://i.imgur.com/WsjO6zJb.png)


Пожалуйста, попробуй:
if (/entertainments/.test(window.location.href) || /suggestions/.test(window.location.href)) {
//code here
console.info("Matches the req...");
}
Поскольку у вас будет одно из них истинным, будет выполнено if-body (в данном случае console.info("Matches the req...");)
Пытаться
if (/entertainments/.test(window.location.href)||/suggestions/.test(window.location.href) )
Пожалуйста, объясните, что здесь происходит.
Измените свое регулярное выражение на это
/^(entertainment|suggestion)/.test(window.location.href);
Спасибо, это сработало отлично и имеет смысл.