1
RanSS9
73d

I feel like I didn't do this right and I'm a tad confused as to what they mean when they say that the function should look like this when you call it:
let line = openingLine(verb: "row", noun: "boat")

Is my solution correct?

Comments
  • 3
    Looks good. If I were being picky I’d suggest that the input arguments should be lower case, and then you should uppercase the first one.
  • 0
    @joycestick This is to have an output of "Row, row, row your boat." basically you're saying to capitalize the first word being Row?
  • 1
  • 1
    @joycestick Thanks so much! I have a habit of overthinking or over complicating and I try to keep it simple.
  • 1
    @RanSS9 It’s easily done. You could add loads of additional case checks etc. to this, but that’s not in the brief. That’s one of the hardest things as a developer - knowing how much to check and future proof, but knowing when to stop. I think you’ve judged this one well.
  • 0
    @joycestick Im still struggling with:

    let line = openingLine(verb: "Row", noun: "Boat")

    I think the "let line" is the part the throws me off. Why is it there? Is it just saying the line: openingLine(verb: "Row", noun: "Boat") is a constant line that reads as follows i.e. openingLine(verb: "Row", noun: "Boat") ?

    I may be overthinking it but I don't get why they bother saying, "...the function should look like the let line" if "let line" part isn't in the function. It throws me off.

    let line = openingLine(verb: "Row", noun: "Boat")
  • 0
    @RanSS9 I think you just need to rename your function to openingLine. Then if someone wanted to use your function to get the opening line of the song and set it to a variable called line, then their line of code would be:

    let line = openingLine(verb: "row", noun: "boat")

    That line isn't actually in your function, it's an example of how they would call your function.
  • 0
    @joycestick

    func openingLine(verb: String, noun: String) -> String {

    return "Row, \(verb), \(verb) your \(noun)."

    }

    openingLine(verb: "row", noun: "boat")
  • 1
    @RanSS9 I don't think you should hardcode Row into the function, otherwise someone calling:

    openingLine(verb: "drive", noun: "car")

    would get:

    Row, drive drive your car

    My solution to the exercise would be:

    func openingLine(verb: String, noun: String) -> String {

    let lowerCaseVerb = verb.lowercased()

    let lowerCaseNoun = noun.lowercased()

    return "\(verb), \(lowerCaseVerb), \(lowerCaseVerb) your \(lowerCaseNoun)"

    }
  • 0
    @joycestick OMG thanks that was driving me nuts on how I should deal with that scenario.
Your Job Suck?
Get a Better Job
Add Comment