-
-
Save TheMuellenator/4bfc62a9f5226e10246fbb08e19bdea3 to your computer and use it in GitHub Desktop.
//Write your code here. | |
// Solution | |
let secondsInAnHour = 3600 | |
// alternatively: | |
// let secondsInAnHour: Int = 3600 | |
// Note, constants can only be set once and cannot be assigned a new value. | |
// The below does not work, because it is a constant and thus cannot be changed. | |
// secondsInAnHour = 1337 | |
//Don't change the code below. | |
print(secondsInAnHour) |
hey @TheMuellenator was this a trick question? Is it as simple of let secondsInAnHour = 3600?
I thought we had to select one of the seconds in the hour. Just double checking!
Yes, very easy! Didn't expect so solution...
WTH is the solution, it makes no sense...
"This does not work, because it is a constant and thus cannot be changed"??????
weren't we meant to declare it as a constant?
Solution with type-checking
let secondsInAnHour: Int = 3600
print(secondsInAnHour)
I thought it had to be something a little bit more complicated, like with some sort of math equation LOL
There are many ways to complete this challenge. I used this code below and passed:
let sencondInAnHour = Int(3600)
please mullenator.can u please explain the question. i am not getting what is the question
Hi! What if I write var instead of let?
Hi! What if I write var instead of let?
It will work, But no mean to use var keywords for constants (as it was immutable value).
- Use var for variables
- Use let for constants
func exercise() {
//Write your code here.
let secondsInAnHour: Int = 3600
//Don't change the code below.
print(secondsInAnHour)
}
LOL! Only here did I realize that I was wasting all this time adding minutes rather than seconds in the hour! 🤣🤦♂️
My solution:
let secondsInAnHour: Int = 60*60
//Don't change the code below.
print(secondsInAnHour)
func exercise() {
let secondsInAnHour = 60 * 60
print(secondsInAnHour)
}
This was a straight forward answer, I even looked for some tricks too
var hour = 1;
var min = 60
var sec = 60
let secondsInAnHour = hour * min * sec;
print(secondsInAnHour);
let secondsInAnHour = 3600
print(secondsInAnHour)
let secondsInAnHour = 60 * 60
print(secondsInAnHour)
func exercise() {
//Write your code here.
let secondsInAnHour: Int = 3600
//Don't change the code below.
print(secondsInAnHour)
}
hey @TheMuellenator was this a trick question? Is it as simple of let secondsInAnHour = 3600?
I thought we had to select one of the seconds in the hour. Just double checking!