If you need a solution, you can create a function to handle this. It seems like you're specifically searching for 2 variables within an array. Here's my approach:
function checkArray(arr, first, second){
let found = false;
if(arr.includes(first) && arr.includes(second)){
found = true;
}
return found;
}
checkArray(["apple", "orange"], "apple", "orange");
If your requirement is for an array with the exact same length, you can include a length check in the function as well. The updated function would look like this:
function checkArray(arr, first, second){
let found = false;
if(arr.length != 2) {
return false;
}
if(arr.includes(first) && arr.includes(second)){
found = true;
}
return found;
}
checkArray(["apple", "orange"], "apple", "orange");