Jump to content
Larry Ullman's Book Forums

timb

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by timb

  1. Hi, Just stumbled on this thread. I'm curious - WHY would you add the 'return:true' to your utilities.js? It's not in Larry's original - what impact would this have on the overall impact once it's integrated into the page? thanks, Tim
  2. Hi, I don't know if anyone's still watching this thread, but I'm stumped. I've been working through this book sequentially without any problems up until this last 'review and pursue' task 'combine employee.js and tasks.js to create a list of employees'. I understand the concept, but what I can't figure out, after much effort, is how to create a new object. Or rather - I can create a new object, but each time I try to add it to the 'newHires' array, it deletes the previous, and the 'newHires.length' returns '1'. I've gone through the above many times, read the relevant chapter sections again, looked at the code in tasks.js again and again - but don't understand why the following code doesn't work. Any help appreciated as I really want to figure this out and feel it's something simple I'm missing. Great book Larry - been trying many javascript/ programming resources over the years, this is the first one that really sticks, both for javascript and the concepts of programming generally. function process() { 'use strict'; //Get a reference for the HTML elements var firstName = document.getElementById('firstName').value; var lastName = document.getElementById('lastName').value; var department = document.getElementById('department').value; //Get a reference for the output var output = document.getElementById('output'); //Create a new object, representing the employee var employee = { firstName: firstName, lastName: lastName, department: department, hireDate: new Date() }; //End of object var newHires=[]; console.log(employee.firstName); newHires.push(employee.firstName); console.log(newHires); console.log(newHires.length); //Main problems seems to be here - employee objects not being added to the array - 'employees.length' returns '1' each time. // Attempt at separating objects with a loop /*for (var i = 0, counter = newHires.length; i < counter; i++) { //Add items to an array console.log(newHires.firstName); };*/ //Display the output //output.innerHTML = message; //Return false to prevent submission return false; }//end function Thanks, Tim
×
×
  • Create New...