Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@dianezev
Copy link

Hi James -

  1. I declare 'theDate' outside of my var publicAPI statement (but inside the IIFE), and then I use the setDate method to set the value of 'theDate'. Do I need to do it that way in order to have access to 'theDate' in my other API methods, or is there a way to reach it if I declare the var 'theDate' inside of the setDate method?
  2. In order to test my js code, I added a basic index.html file and added some console.log test code at the bottom of my js file. Is that what you're expecting us to do, or is there another way I should be testing this?
  3. I assumed that the setDate method was supposed to be flexible and store 'theDate' EITHER as a Date object OR in epoch milliseconds, depending on the argument that was passed. Is that correct, or should I have forced all the dates to Date objects? (my other methods call a function to convert date to an object if I need to use a Date method such as getTime.) If I did this incorrectly, should I resubmit the HW?
    Thank you!
    Diane

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functions works as written, so my only feedback is just an implementation optimization. Notice how the getDay and getMonth return a number starting with 0? Think of how you can represent the day names and month names as values starting with 0 (hint: there's a particular data structure this maps very well to.) This would allow you to externalize configuration data like this as part of the private data of your module and the methods would have access to that data when returning the specific day or month string respectively.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi James,

Thanks so much for the detailed comments - I really appreciate the input. I think your hint was referring to using arrays for the weekday & month labels, and I'm not sure what "externalize configuration data" means. Can you please let me know if either of these are on the right track? Thank you! (I see that .toLocaleDateString is another option that doesn't yet work in all browsers.)

  1. Just use var weekdayLabels = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; inside my getDayName function and return weekdayLabels[dayValue]; . (Same for getMonthName).

  2. OR, declare an object var outside of my IIFE (instead of inside??) that looks something like this (and then reference it inside my IIFE with dateLabels.getWeekdayLabel(dayValue) ):

var dateLabels = {
getWeekdayLabel: function getWeekdayLabel(weekday) {
var weekdayLabels = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday',
'Friday', 'Saturday'];

return weekdayLabels[weekday];
},

getMonthLabel: function getMonthLabel(month) {
var monthLabels = ['January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December'];

return monthLabels[month];
}
};

#2 above worked for me, but I wanted to check to see if that was what you had in mind. Partly, I'm not sure what it means to externalize data (put it in a separate .js file, or put it in the same .js file outside of the IIFE?). And would we externalize something like this just because it's generic data that might be referenced by a variety of other functions, or is it more efficient to define the dateLabels object outside of the IIFE?

Thank you!

Diane
----- Original Message -----

From: "jamdon" notifications@github.com
To: "JSCRIPT300-Spring2015/Module_2" Module_2@noreply.github.com
Cc: "dianezev" dianezev@comcast.net
Sent: Saturday, April 11, 2015 6:18:07 PM
Subject: Re: [Module_2] Module 2 HW Diane Zevenbergen (#2)

In app/js/enhancedDate.js :

  •            return getDateMilli(theDate);
    
  •        }  
    
  •    },
    
  •    // Return day of week ('Monday', etc.)
    
  •    getDayName: function getDayName() {
    
  •        var dayValue;
    
  •        var dayLabel;
    
  •        verifyDate();
    
  •        // Use getDay method on Date obj (getDateObj fcn converts from ms to obj if needed)
    
  •        dayValue = getDateObj(theDate).getDay();
    
  •        // Assign weekday label based on weekday value
    
  •        switch (dayValue) { 
    

Functions works as written, so my only feedback is just an implementation optimization. Notice how the getDay and getMonth return a number starting with 0? Think of how you can represent the day names and month names as values starting with 0 (hint: there's a particular data structure this maps very well to.) This would allow you to externalize configuration data like this as part of the private data of your module and the methods would have access to that data when returning the specific day or month string respectively.


Reply to this email directly or view it on GitHub .

@jamdon
Copy link
Contributor

jamdon commented Apr 12, 2015

Great job. 👍

@jamdon jamdon closed this Apr 12, 2015
@jamdon
Copy link
Contributor

jamdon commented Apr 12, 2015

One more thing I forgot to add, you should include a 'use strict'; inside your code. Modules are well suited for this as they are wrapped in an enclosing function already, and the 'use strict'; directive can go inside the IIFE and be applied to all the functions appearing inside as well.

AnotherGriffith added a commit to AnotherGriffith/Module_2 that referenced this pull request May 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.