Swift Tutorial | Question-Bot

Hey guys,

I'm doing the first Swift Tutorial and I'm in chapter two with the questionbot.

There is a task where is should I made it possible to give the robot 3 standard answers... but I don't know how... I tried everything. :')

Pls help me :D

func responseTo(question: String) -> String {



    let lowerQuestion = question.lowercased()



    if lowerQuestion == "Wo sind die kekse?" {

        return "In der Keksdose!"

    } else if lowerQuestion.hasPrefix("wo") {

        return "In den Norden!"

    } else {



        let defaultNumber = question.count % 4



        if defaultNumber == 0 {

            return "Das kommt ganz darauf an"

        } else {

            return "Frag mich morgen noch einmal"
        }



    }

}

responseTo(question: "Wo sind die Kekse?")

responseTo(question: "Kann ich einen Keks haben?")

responseTo(question: "BITTE, kann ich einen Keks haben?")

Can you explain better the problem ? What do you get ? What did you expect. What did you try ?

What is the purpose of this ?

        let defaultNumber = question.count % 4

You test how many chars in the text of the question, really ?

Swift Tutorial | Question-Bot
 
 
Q