javascript - depName is not defined -
it tells me depname undefined.i trying iterate,just can see whats wrong it.i trying profitable department out of array.
var salesdata = [ {department : 'hardware', sales : 4500, day : 'monday'}, {department : 'outdoor', sales : 1500, day : 'monday'}, {department : 'carpentry', sales : 5500, day : 'monday'}, {department : 'hardware', sales : 7500, day : 'tuesday'}, {department : 'outdoor', sales : 2505, day : 'tuesday'}, {department : 'carpentry', sales : 1540, day : 'tuesday'}, {department : 'hardware', sales : 1500, day : 'wednesday'}, {department : 'outdoor', sales : 8507, day : 'wednesday'}, {department : 'carpentry', sales : 8009, day : 'wednesday'}, {department : 'hardware', sales : 12000, day : 'thursday'}, {department : 'outdoor', sales : 18007, day : 'thursday'}, {department : 'carpentry', sales : 6109, day : 'thursday'}, {department : 'hardware', sales : 7005, day : 'friday'}, {department : 'outdoor', sales : 12006, day : 'friday'}, {department : 'carpentry', sales : 16109, day : 'friday'}, ]; var depmap = {}; function mostprofitabledepartment() { (var = 0; < depname.length; i++) { var currentdep = depname[i] } console.log(currentdep); } mostprofitabledepartment(salesdata);
you forgot set parameter on function mostprofitabledepartment
// missing depname in function declaration function mostprofitabledepartment(depname) { (var = 0; < depname.length; i++) { var currentdep = depname[i]; console.log(currentdep); // outside of loop } }
Comments
Post a Comment