Answer the question
In order to leave comments, you need to log in
How can I convert a negative number to a positive number in a function?
You need to find the opposite number given. For example, there is 1, you need to find -1.
I tried with negate (it didn't work because I don't know how to use it correctly), I tried with if (but I don't understand what condition I should write). My code:
if number < 0 {
return number * -number Codewars
problem, initial conditions:
func opposite(number: Double) -> Double {
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question