Skip to content

Module 2 pull request by Sam Negassi#11

Closed
samNson wants to merge 3 commits intoJSCRIPT300-Spring2015:masterfrom
samNson:master
Closed

Module 2 pull request by Sam Negassi#11
samNson wants to merge 3 commits intoJSCRIPT300-Spring2015:masterfrom
samNson:master

Conversation

@samNson
Copy link

@samNson samNson commented Apr 16, 2015

I've created the Module Pattern for the enhancedDate object. I had difficulty type testing when no argument is submitted when setDate() method is called. I tried
if (typeof arg === "undefined") { date = new Date } ;
to address that case but when i call the getDate() to see the result, i got NaN as output. So i scrapped that code and used a more forgiving one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately you can't do this in JavaScript yet. With ES6 you'll be able to set default arguments in this fashion, but for now, you need to just pass in arg and assign it a value inside the setDate: function (arg) {

@jamdon
Copy link
Contributor

jamdon commented Apr 17, 2015

👍

@jamdon jamdon closed this Apr 17, 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