Giter Club home page Giter Club logo

swift-functionfun-lab-ios-apply-000's Introduction

Function Fun

Theo

The whole purpose of education is to turn mirrors into windows. -Sydney J. Harris

Learning Objectives

  • Create functions that take in no arguments and return a String.
  • Create functions that take in arguments of various types and return a String.
  • Perform math and string interpolation in your implementation of a function.
  • Have fun.

Instructions

Setup

  • Open up the FunctionFun.xcworkspace file included along with this repo.
  • Locate the ViewController.swift file (when in Xcode), this is where you will be writing your code. You should find the following comment:
// implement your functions here.
  • Feel free to remove that comment, that is where you will be creating your functions.
  • You should also notice that there's a ViewControllerTests.swift file in the left pane as well. Feel free to explore how these tests were written and what these tests are looking for.
  • You can read about how you will be working with the tests here.
  • While implementing your functions, press command + u to get these tests to run. You should see the following green checkmark when you run the tests (using command + u) after ALL of your functions have been implemented correctly.

test

  • If your tests didn't pass, you should see various errors within the ViewControllerTests.swift file telling you WHY.

  • Here's an example of what it looks like when one of the tests aren't passing:

TestExample


Code Time!

1 - Create a function called greet(_:) which takes in one argument of type String which represents someones name and returns a String. Someone calling on this function might give it the name "Jim", where the String being returned would look like this: 'Hello Jim!'.

2 - Create a function called frozen() which takes in no arguments but returns back a String. Implement this function so that when it is called, the String it should return is 'Let it go!'. For those that have never heard this song before, you can listen to it here.

3 - Create a function called favoriteCharacter(_:) which takes in one argument of type String which represents the name of a character and returns a String. If someone called on this function, passing in as a argument "Crystal", the String returned would look like this: 'My favorite character is Crystal.'.

4 - Create a function called problems(_:) which takes in as an argument an Int which represents a number and returns a String. If the number passed in was 99, the String that would be returned would be as follows: 'I got 99 problems but Swift ain't one.'.

5 - Create a function called uppercaseCatchphrase(_:) which takes in a String as an argument representing someones name and returns back a String. If the name passed in was "Becca", the return String should be: 'TO INFINITY AND BEYOND, BECCA!'. The entire String should be returned back all uppercased.

6 - Create a function called isEven(_:) which takes in an Int as an argument which represents a number and returns back a Bool. In your implementation, you should check to see that the number passed into this function as an argument is divisible by 2, if it is you should return true, if it is not, you should return false.


View this lesson on Learn.co

swift-functionfun-lab-ios-apply-000's People

Contributors

jimcampagno avatar annjohn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.