Skip to content

More correct solution for #2 #1

Description

@thefriendlydev

For question 2 you state:
If there is more than one argument, create a property, otherArgs that is an array of the remaining arguments.

Your solution in the videos returns otherArgs no matter the size of arguments.length wouldn't something like this be a little better?

var AnimalTestUser = function (username) {
  var numArgs = arguments.length
  if (numArgs === 1) {
    return {
      username: username
    }
  } else if (numArgs > 1) {
    var otherArgs = []
    for (var i = 1; i < numArgs; i++) {
      otherArgs.push(arguments[i])
    }

    return {
      username: username,
      otherArgs: otherArgs
    }
  } else {
    console.log('Opps we need some arguments!')
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions