mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix: add missing test case and fix double semicolon in screaming snake case challenge (#66458)
This commit is contained in:
+7
-1
@@ -55,6 +55,12 @@ assert.equal(toScreamingSnakeCase("user-address"), "USER_ADDRESS");
|
||||
assert.equal(toScreamingSnakeCase("username"), "USERNAME");
|
||||
```
|
||||
|
||||
`toScreamingSnakeCase("my_variable_name")` should return `"MY_VARIABLE_NAME"`.
|
||||
|
||||
```js
|
||||
assert.equal(toScreamingSnakeCase("my_variable_name"), "MY_VARIABLE_NAME");
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
@@ -73,6 +79,6 @@ function toScreamingSnakeCase(variableName) {
|
||||
let temp = variableName.replace(/[-_]+/g, ' ');
|
||||
temp = temp.replace(/([a-z0-9])([A-Z])/g, '$1 $2');
|
||||
const words = temp.trim().split(/\s+/);
|
||||
return words.join('_').toUpperCase();;
|
||||
return words.join('_').toUpperCase();
|
||||
}
|
||||
```
|
||||
|
||||
+9
@@ -70,6 +70,15 @@ TestCase().assertEqual(to_screaming_snake_case("username"), "USERNAME")`)
|
||||
}})
|
||||
```
|
||||
|
||||
`to_screaming_snake_case("my_variable_name")` should return `"MY_VARIABLE_NAME"`.
|
||||
|
||||
```js
|
||||
({test: () => { runPython(`
|
||||
from unittest import TestCase
|
||||
TestCase().assertEqual(to_screaming_snake_case("my_variable_name"), "MY_VARIABLE_NAME")`)
|
||||
}})
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
Reference in New Issue
Block a user