<header> <h1>Form</h1> </header> <body> <script> obj = { "Name": "chevrolet chevelle malibu", "Cylinders": 8, "Displacement": 307, "Horsepower": 130, "Weight_in_lbs": 3504, "Origin": "USA", "in_production": false }; const createForm = () => { const typesMap = { 'boolean': 'checkbox', 'number': 'number', 'string': 'text' }; let str = "<form>\n"; for (var name in obj) { value = obj[name]; type = typeof value; htmlType = typesMap[type]; str += ` <label>${name}: <input type="${htmlType}" value="${value}" /></label>\n`; } str += "</form>"; return str; } str = createForm(obj); document.write(str); alert(str); </script> </body>