-
-
Save TheMuellenator/ceed75150b5f7127c8bf38b3564e7ca3 to your computer and use it in GitHub Desktop.
////Don't change this | |
var aNumber = Int(readLine()!)! | |
func dayOfTheWeek(day: Int) { | |
//Write your code inside this function. | |
switch day { | |
case 1: | |
print("Monday") | |
case 2: | |
print("Tuesday") | |
case 3: | |
print("Wednesday") | |
case 4: | |
print("Thursday") | |
case 5: | |
print("Friday") | |
case 6: | |
print("Saturday") | |
case 7: | |
print("Sunday") | |
default: | |
print("Error") | |
} | |
} | |
//Don't change this | |
dayOfTheWeek(day: aNumber) |
So basically I just did a reset on the challenge page and then just tried again.
Only use this.
switch day {
case 1:
print("Monday")
case 2:
print("Tuesday")
case 3:
print("Wednesday")
case 4:
print("Thursday")
case 5:
print("Friday")
case 6:
print("Saturday")
case 7:
print("Sunday")
default:
print("Error")
oh my....as usual it would give me errors again, while working in my playground....so came here to check...you all have the same, I mean this one is quite easy....in the end I didn't copy and paste the last }...(smacks own head)
This worked for me
{ switch day { case 1: print ("Monday")
case 2: print ("Tuesday")
case 3: print ("Wednesday")
case 4: print ("Thursday")
case 5: print ("Friday")
case 6: print ("Saturday")
case 7: print ("Sunday")
default: print ("Error")
}
}
////Don't change this
var aNumber = Int(5)
func dayOfTheWeek(day: Int) {
switch day {
case 1:print("Monday")
case 2:print("Tuesday")
case 3:print("Wednesday")
case 4:print("Thursday")
case 5:print("Friday")
case 6:print("Saturday ")
case 7:print("Sunday ")
default:print("Error")
}
}
//Try out some different numbers here
//Don't copy the line below into Udemy
dayOfTheWeek(day: 5)
////Don't change this
func dayOfTheWeek(day: Int) {
let day = Int.random(in: 1...7)
switch day {
case 1:
print("monday")
case 2:
print("tuseday")
case 3:
print("wansday")
case 4:
print("tuseday")
case 5:
print("friday")
case 6:
print("seterday")
case 7:
print("sunday")
default:
print("error")
}
}
dayOfTheWeek(day: 4)
//Try out some different numbers here
//Don't copy the line below into Udemy
var aNumber = Int(readLine()!)!
// Function to determine the corresponding day of the week. It takes an integer day as a parameter
func dayOfTheWeek(day: Int) {
switch day {
case 1:
print("Monday")
case 2:
print("Tuesday")
case 3:
print("Wednesday")
case 4:
print("Thursday")
case 5:
print("Friday")
case 6:
print("Saturday")
case 7:
print("Sunday")
default:
print("Error")
}
}
// We call the function with the user input integer aNumber as the argument and it prints the day of the week to the console
dayOfTheWeek(day: aNumber)
////Don't change this
var aNumber = Int(readLine()!)!
func dayOfTheWeek(day: Int) {
//Write your code inside this function.
switch(day) {
case 1:
print("Monday")
case 2:
print("Tuesday")
case 3:
print("Wednesday")
case 4:
print("Thursday")
case 5:
print("Friday")
case 6:
print("Saturday")
case 7:
print("Sunday")
default:
print("Error")
}
}
This is how I did it, it was super fun.
var aNumber = 1 // you can insert your own number here
func dayOfTheWeek(day: Int) {
let daysArray = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
switch day {
case 1...daysArray.count:
print(daysArray[day - 1])
default:
print("Error")
}
}
dayOfTheWeek(day: aNumber)
https://gist.github.com/TheMuellenator/ceed75150b5f7127c8bf38b3564e7ca3#gistcomment-3687911
Hope it will help you 👍