Create a function that takes a number n as its only argument and prints "negative" to the console if n is less than zero, otherwise prints "positive" to the console.
Example 1:
Input: n = 5
Output: "positive"
Explanation:
5 is greater than or equal to zero, so our function prints "positive" to the console.
Example 2:
Input: n = 0
Output: "positive"
Explanation:
0 is greater than or equal to zero, so our function prints "positive" to the console.
Example 3:
Input: n = -2
Output: "negative"
Explanation:
-2 is less than zero, so our function prints "negative" to the console.
Hints:
You can make use of
You can add an
You can make use of
< operator with an if statement to check if n is negative.
You can add an
else statement to handle the case when n is positive.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check