Requirements: All tasks must be written in JavaScript. You can only use following native operators in our examples and you cannot initialize any extra variables.
Don’t use loops, switch or any other JavaScript operators, also functions and plugins
Example-1. function sign(n){
if (n > 0) return 1;
else return -1;
}
sign(2)
1
sign(-5)
-1
Example-2. (n > 1)The sum of numbers from 1 to n function sum(n) {
if (n == 1) return 1;
else sum(n - 1) + n;
}