Lesson 4 of 15
Conditionals
Conditionals
Swift if/else if/else work like most languages:
let score = 85
if score >= 90 {
print("A")
} else if score >= 80 {
print("B")
} else {
print("C")
}
// B
Comparison Operators
==, !=, <, >, <=, >=
Logical Operators
&& (and), || (or), ! (not)
Your Task
Write a function sign that takes an Int and returns:
"positive"if the number is greater than 0"negative"if less than 0"zero"if equal to 0
JS Transpiler loading...
Loading...
Click "Run" to execute your code.