File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed
Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ function solution ( my_string ) {
2+ const REGEX = / [ a - z ] / ;
3+ let word = my_string . split ( "" ) ;
4+ let answer = [ ] ;
5+
6+ for ( let i = 0 ; i < my_string . length ; i ++ ) {
7+ if ( word [ i ] . match ( REGEX ) ) {
8+ answer . push ( word [ i ] . toUpperCase ( ) ) ;
9+ } else answer . push ( word [ i ] . toLowerCase ( ) ) ;
10+ }
11+
12+ return answer . join ( "" ) ;
13+ }
Original file line number Diff line number Diff line change 1+ function solution ( my_string , num1 , num2 ) {
2+ const answer = my_string . split ( "" ) ;
3+ const temp = answer [ num1 ] ;
4+ answer [ num1 ] = answer [ num2 ] ;
5+ answer [ num2 ] = temp ;
6+
7+ return answer . join ( "" ) ;
8+ }
Original file line number Diff line number Diff line change 1+ function solution ( num ) {
2+ const number = Math . abs ( num ) ;
3+ if ( number % 2 === 1 || number < 0 ) return "Odd" ;
4+ if ( number % 2 === 0 || number === 0 ) return "Even" ;
5+ }
You can’t perform that action at this time.
0 commit comments