Previous episode: 23. Return Data From Functions
Next episode: 25. Conclusion
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
To really master functions, I've prepared two challenges for you. And the first one, you have to create a function which takes in two parameters, the first and the last name. Then it has to return the length of the full name. Live the last name as an empty string by default, as some people don't have one. And the second challenge you have to overload the initial function to accept a middle name because some people have one. Then use those two functions to print out the length of two names. Remember to use named arguments when needed when calling function. That's it. Now pause the video and try to solve the challenges. Then once you done hit the play button to check out my solution. (upbeat music) Start off by declaring the function as follows. This function is pretty simple, it sums the length of these two strings. Then print out the name length by calling the function like so. Run the project and you should see the length. Now for the second challenge overload the function to add a middle name parameter like so. Finally print out the length of the name with the middle name. Run the project and you should see the length of their full name. And that's quite a long name.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.