Make a Person - error

Tell us what’s happening:
Hello everyone,
The code below seem to work in a browser with no errors but the emulator here tells me: “TypeError: Cannot set property ‘firstName’ of undefined” - why?

Your code so far

var Person = function(firstAndLast) {
    const argsFromArray = Array.from(arguments)
    this.firstName = ''
    this.lastName = ''
    var fullName = this.firstName + ' ' + this.lastName
    
    function checkArgs (argsArrayToCheck) {
        if (argsArrayToCheck.length > 1) {
            console.log('More than 1 argument provided, stopping here.', argsArrayToCheck)
            return false
        } else if (typeof(argsArrayToCheck[0]) !== 'string') {
            console.log('You did not provide a string as argument, argument is a:', typeof(argsArrayToCheck[0]))
            return false
        } else {
            nameArray = argsArrayToCheck[0].split(' ')
            console.log('Valid argument provided')
            this.firstName = nameArray[0]
            this.lastName = nameArray[1]
            return this.firstName, this.lastName, true
        }
    }

    if (checkArgs(argsFromArray)) { // if the arguments provided are OK
        this.getFullName = function() {
            var fullName = firstName + ' ' + lastName
            console.log('Full name:', fullName)
            return fullName
        }
    
        this.getFirstName = function() {
            console.log('First name:', firstName)
            return firstName
        }
    
        this.getLastName = function() {
            console.log('Last name:', lastName)
            return lastName
        }

        this.setFirstName = function(first) {
            firstName = first
            console.log('New first name:', firstName)
            return firstName
        }

        this.setLastName = function(last) {
            lastName = last
            console.log('New last name:', lastName)
            return lastName
        }
    }
    
    this.setFullName = function(firstAndLast) {
        const newArgsFromArray = Array.from(arguments)
        
        if (checkArgs(newArgsFromArray)) { // if the new arguments provided are OK
            this.setFirstName = function(first) {
                firstName = first
                console.log('New first name:', firstName)
                return firstName
            }
    
            this.setLastName = function(last) {
                lastName = last
                console.log('New last name:', lastName)
                return lastName
            }

            var fullName = firstName + ' ' + lastName
            console.log('NEW Full name:', fullName)
            return fullName
        }
    }
    
};

var bob = new Person('Bob Ross');```
**Your browser information:**

Your Browser User Agent is: ```Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3256.0 Safari/537.36```.

**Link to the challenge:**
https://www.freecodecamp.org/challenges/make-a-person

Weird, this is how the code was pasted automatically - i edited the original input, now everything is there.

Nobody willing to help?

Thank you @camperextraordinaire - apologies for late reply. I will have another go at it.

It’s amazing how big of a difference makes taking a break:slight_smile:

var Person = function(firstAndLast) {
    // Complete the method below and implement the others similarly
    var firstName, lastName 
    var nameArray = firstAndLast.split(' ')
    firstName = nameArray[0]
    lastName= nameArray[1]

    this.getFullName = function() {
        var fullName = firstName + ' ' + lastName
        console.log(firstName + ' ' + lastName)
        return fullName
    };
    this.getFirstName = function() {
        console.log(firstName)
        return firstName
    };
    this.getLastName = function() {
        console.log(lastName)
        return lastName
    };
    this.setFirstName = function(first) {
        firstName = first
        return firstName
    };
    this.setLastName = function(last) {
        lastName = last
        return lastName
    };
    this.setFullName = function(firstAndLast) {
        nameArray = firstAndLast.split(' ')
        firstName = nameArray[0]
        lastName= nameArray[1]
    };
};