Search code examples
swiftinteger

how to convert hour to seconds in swift?


I need to convert this code to an hours

func convert_to_seconds(hours: Int) -> Int {
    // write your code here
    }

the input is:

 hours = 6

the output is:

 21600

I tried several codes but they didn't work for me


Solution

  • func convert_to_seconds(hours: Int) -> Int {
        hours*3600
    }