Why wont my loop within a loop in Javascript work? <p>This is suppose to store the chosen answer for multiple questions. When I use this code, it only checks the first question and disregards the other questions.</p> <pre><code> for(i = 0; i &lt; questions.length-1; i++){ radios = document.getElementsByName(questions[i]); for (var t = 0; length &lt; radios.length; t++) { if (radios[t].checked) { var qResults = JSON.parse(localStorage["qResults"]); num = radios[t].value; checked = num.toString(); var temp = (id[0] + ";" + questions[i] + ";" + checked); alert(temp); qResults.push(temp); localStorage["qResults"] = JSON.stringify(qResults); } } alert("question finished"); } </code></pre>