I have a set of multiple-choice questions that a user will answer via radio buttons. Depending on their choices, they will be presented with information relevant to said choices.
I'm using the map function to watch the form and capture the answers in an array:
$('input[type="radio"]').on('change', function() {
var results = $('input[type="radio"]:checked').map(function() {
return this.value;
}).get();
});
This is working well but I am having trouble working out how to, once the answers have been input, to check if they match a predetermined array. Below is what I've tried with no success:
$('.subscription-builder input[type="radio"]').on('change', function() {
var results = $('input[type="radio"]:checked').map(function() {
return this.value;
}).get();
var arrayTestOne = ["Cheese", "Carrot", "Lettuce", "Apple"];
var arrayTestTwo = ["Banana", "Avocado", "Lettuce", "Pear"];
if (results == arrayTestOne) {
console.log('WOOOO!');
} else if (results == arrayTestTwo) {
console.log('Hooray!');
}
});
Any ideas?