i want to show prod name when i click on second buttton then show me pro2 but now here pro2 directly show .why i can't understan
<html> <body> <form> <input type="button" value="question1" id="abut" onclick=" return f1(0)"> <input type="button" value="question2" id="pbut" onclick=" return f1(1)"><br> <label id="guess what??"></label><br><br><br> <label id="guess what1??"></label> </form> <script> var catalog = { "products": [ { "name": "prod 1", "versions": [ "ver 1", "ver 2" ] }, { "name": "prod 2", "versions": [ "ver 1", "ver 2" ] } ] }; function f1(count){ for(var i = 0; i < catalog.products.length; i++) { var product = catalog.products[count]; var productName = product.name; document.getElementById('guess what??').innerHTML= productName; for(var j = 0; j < product.versions.length; j++) { var version = product.versions[j]; } } } </script> </body> </html>