Skip to content

Commit f98dcfd

Browse files
committed
Return Negative
1 parent e19dc08 commit f98dcfd

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

task37.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//Return Negative
2+
/*In this simple assignment you are given a number and have to make it negative. But maybe the number is already negative?
3+
4+
Examples
5+
makeNegative(1); // return -1
6+
makeNegative(-5); // return -5
7+
makeNegative(0); // return 0
8+
makeNegative(0.12); // return -0.12
9+
10+
*/
11+
12+
function makeNegative(num) {
13+
return num > 0 ? -num : num;
14+
}
15+
/*
16+
function makeNegative(num) {
17+
if (num > 0) {
18+
return -num;
19+
} else {
20+
return num;
21+
}
22+
}
23+
*/

0 commit comments

Comments
 (0)