This is the code that I'm trying to run in Swift 4:
import UIKit
func calculatorGame(yourName: String) -> String { let gameScore = arc4random_uniform(101)
if gameScore > 80 {
return "Your game score is \(gameScore). You are a true gamer \(yourName)"
}
else if gameScore <= 80 && > 40 {
return "Your game score is \(gameScore). Just a little more push \(yourName)" \*but this line of code shows me the error from the Swift compiler "Playground execution failed:
error: Conditional Statements.playground:3:32: error: unary operator cannot be separated from its operand else if gameScore <= 80 && > 40 { ^~ *\ } else { return "Your game score is (gameScore). You need more practice (yourName)" } }
print(calculatorGame(yourName: "Yo"))
Aucun commentaire:
Enregistrer un commentaire