Heres an example where you can get either of the patterns you want, we check for an exact match and then use the ||
option to create an OR command and check for a lack of the string &WEEK=
.
Conditions:
// Returns true if "&WEEK=18" is present in string currentURL
currentURL.includes("&WEEK=" + liveScoringWeek)
// Returns true if "&WEEK=" is NOT present in string currentURL, i.e. has an index of -1
currentURL.indexOf("&WEEK=") === -1)
If statement with OR functionality:
// If function requiring either or of two conditions.
// Replace CONDITION_1 with a true/false qualifier
if ( CONDITION_1 || CONDITION_2 ) {
...
}
Let me know if you were hoping for something else.
// Store week variable
var liveScoringWeek = 18
// Check URL Function
function checkURL(currentURL) {
// Check if exact match with week
// Or no presence of &WEEK= in url
if (currentURL.includes("&WEEK=" + liveScoringWeek) || currentURL.indexOf("&WEEK=") === -1) {
// Prove we've found them
console.log("found it!");
}
}
// Add test function to buttons
$(".test").click(function() {
// Check URL taken from button text
checkURL($(this).text());
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button class="test">test.com/?something&O=07</button>
<button class="test">test.com/?something&O=07&WEEK=18</button>
<button class="test">test.com/?something&O=07&WEEK=19</button>