Created
July 8, 2020 02:59
-
-
Save gpDA/b3005cec655d95faf48a76a513ad784b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function student(...args){ | |
| const inputArray = args // [ 'hello', 'world', 'people' ] | |
| this.fname = inputArray[0]; | |
| if (inputArray.length === 3) { | |
| this.mname = inputArray[1]; | |
| this.lname = inputArray[2]; | |
| } else { | |
| this.mname = ''; | |
| this.lname = inputArray[1]; | |
| } | |
| this.getFullName = function (){ | |
| return this.fname + " " + this.mname + " " + this.lname; | |
| } | |
| } | |
| console.log(new student('gp', 'geonpyung', 'lee').getFullName()) // gp geonpyung lee | |
| console.log(new student('gp', 'lee').getFullName()) // gp lee |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment