Hi, I am doing the first question of the last exercise on the following screenshot. However, I don't really understand the two questions. How is it possible to store a result in a constant, if the result itself is declared with 'let', making it a constant? I sure am not understanding correctly the question, understandable with the fact I just started learning code. Here's the block of code.
let total = pigsFlying + frogsBecomingPrinces + multipleLightningStrikes
return total
}
/*:
- callout(Exercise): Update the `impossibleBeliefsCount` function so that instead of printing the value, it returns it as an `Int`.
`impossibleThingsPhrase` creates a phrase using string interpolation:
*/
func impossibleThingsPhrase(numberOfImpossibleThings: Int, meal: String) -> String {
return "Why, I've believed as many as \(numberOfImpossibleThings) before \(meal)"
}
impossibleThingsPhrase(numberOfImpossibleThings: 712, meal: "chicken")
/*:
- callout(Exercise): Update the `impossibleThingsPhrase` function so that, instead of using its two internal constants, it takes two arguments: `numberOfImpossibleThings` as an `Int` and `meal` as a `String`.
Now you have two functions that take parameters and return values.
- callout(Exercise): Call `impossibleBeliefsCount` and store the result in a constant.\
Call `impossibleThingsPhrase`, passing in the result of `impossibleBeliefsCount` as one of the arguments.
*/
func impossibleBeliefsCount(pigsFlying: Int, frogsBecomingPrinces: Int, multipleLightningStrikes: Int) {
let total = pigsFlying + frogsBecomingPrinces + multipleLightningStrikes
return total
}