/* Write your code here to iterate over the form's fields and output the values in each field to the console. Your code should access the FORM object and iterate over the fields rather than get each form field by its ID.
It should also work for a form of any number of fields, and work with any value typed into the field by a user.
*/
// suggested steps
// 1) get the form element from the page
(function() {
var form = document.forms[0];
// 2) iterate over the form's elements array and write each element's value to the console
var formElem = form.elements;
for (var i = 0; i < formElem.length; i++) {
if (formElem[i].type == 'text') {
console.log(formElem[i].placeholder + ": " + formElem[i].value);
}
}
}());
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.