Skip to content

Commit 95b4184

Browse files
committed
using existing library instead create a new function from scratch
1 parent daff116 commit 95b4184

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

Sprint-2/3-mandatory-implement/2-cases.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,25 @@
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"));

0 commit comments

Comments
 (0)