File tree Expand file tree Collapse file tree 1 file changed +20
-16
lines changed
Sprint-2/3-mandatory-implement Expand file tree Collapse file tree 1 file changed +20
-16
lines changed Original file line number Diff line number Diff line change 1515// Use the MDN string documentation to help you find a solution
1616// This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
1717
18- function ConvertToUpperSnakeCase ( s1 )
19- {
20- let result = "" ;
21- for ( let i = 0 ; i < s1 . length ; i ++ )
22- {
18+ // function ConvertToUpperSnakeCase(s1)
19+ // {
20+ // let result = "";
21+ // for(let i=0;i<s1.length;i++)
22+ // {
2323
24- if ( s1 [ i ] === " " )
25- {
26- result += s1 [ i ] = "_" ;
27- }
28- else
29- result += s1 [ i ] ;
30- }
31- let UPPER_SNAKE_CASE = result . toUpperCase ( ) ;
32- return UPPER_SNAKE_CASE ;
33- }
34- console . log ( ConvertToUpperSnakeCase ( "Ahmad Hmedan" ) ) ;
24+ // if(s1[i]===" ")
25+ // {
26+ // result+=s1[i]="_";
27+ // }
28+ // else
29+ // result+=s1[i];
30+ // }
31+ // let UPPER_SNAKE_CASE=result.toUpperCase();
32+ // return UPPER_SNAKE_CASE;
33+ // }
34+ // console.log(ConvertToUpperSnakeCase("Ahmad Hmedan"));
3535
36+ function convertToUpperSnakeCase ( str ) {
37+ return str . replaceAll ( " " , "_" ) . toUpperCase ( ) ;
38+ }
39+ console . log ( convertToUpperSnakeCase ( "Ahmad Hmedan" ) ) ;
You can’t perform that action at this time.
0 commit comments