I have a method that creates 2 arrays with data. I want to be able to include these arrays into JSON. Here is my code:
$(document).ready(function() {
$("button").click(function(){
var configs = [];
var testPages = [];
$(".test input:checked").each(function() {
testPages.push($(this).attr('id'));
});
$(".config input:checked").each(function() {
configs.push($(this).attr('id'));
});
//console.log(configs);
//console.log(testPages);
var testJson = new Object();
testJson.testpages = testPages;
testJson.configurations = configs;
var runTestJson = JSON.stringify(testJson);
return runTestJson;
});
});
I want to be able to test this against my page but I am new to jQuery, Javascript and also using Chrome developer tools. I'm not sure how to test this in the Chrome console.
The commented portion (console.log()s) were displayed but when I type configs or testPages to try to view the array, I would get the error that they were undefined. How do I test to see if I am getting the correct output for my code on Chrome developer tools?
