Check out example codes for "fizbuzz in swift". It will help you in understanding the concepts better.

Code Example 1

func fizzBuzz() {
    for i in 1...100
    {
        if i % 3 == 0 && i % 5 == 0
        {
            print("FizzBuzz")
        } else if i % 3 == 0
        {
            print("Fizz")
        } else if i % 5 == 0
        {
            print("Buzz")
        } else
        {
            print(i)
        }
    }
}

Learn ReactJs, React Native from akashmittal.com