File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ Write a function called odd_even() which takes an integer value and tells whether this value is even or odd. You need to do it in 4 ways:
2+ Has return+ Has parameter
3+ No return+Has parameter
Original file line number Diff line number Diff line change 1+ /* Write a function called odd_even() which takes an integer value and tells whether this value is even or odd. You need to do it in 4 ways:
2+ - Has return + Has parameter
3+ - No return + Has parameter */
4+
5+
6+
7+ // Has return+ Has parameter
8+
9+
10+ function odd_even ( num ) {
11+ if ( num % 2 == 0 ) {
12+
13+ return num + " is an even number." ;
14+ }
15+
16+ else {
17+ return num + " is an odd number." ;
18+ }
19+ } ;
20+
21+ var randomNum = odd_even ( 16 ) ;
22+ console . log ( randomNum ) ;
23+
24+
25+ // No return + Has parameter
26+
27+ function odd_even ( num ) {
28+ if ( num % 2 == 0 ) {
29+ console . log ( num , " is an Even number." ) ;
30+ }
31+ else {
32+ console . log ( num , " is an Odd number." ) ;
33+ }
34+ }
35+
36+ odd_even ( 50 ) ;
37+
You can’t perform that action at this time.
0 commit comments