pour waim
This commit is contained in:
1 parent
f792f15caa
commit
0dd3b65a74
2 files changed
+216
-13
No files matched your search
+33
-3
@@ -1,4 +1,7 @@
|
||||
class CaseUtil{
|
||||
|
||||
constructor() {
|
||||
}
|
||||
toSnakeCase(s){
|
||||
return s.replaceAll(" ", "_");
|
||||
}
|
||||
@@ -7,7 +10,6 @@ class CaseUtil{
|
||||
return s.replaceAll(" ", "-");
|
||||
}
|
||||
|
||||
|
||||
toCamelCase(s){
|
||||
while(s.indexOf(" ") !== -1){
|
||||
const idx = s.indexOf(" ");
|
||||
@@ -31,6 +33,34 @@ class CaseUtil{
|
||||
|
||||
}
|
||||
|
||||
const caseUtil = new CaseUtil();
|
||||
|
||||
alert(caseUtil.toAlexandreCase("bonjour le monde"))
|
||||
|
||||
class CaseWord{
|
||||
constructor(underlyingText) {
|
||||
this.underlyingText = underlyingText;
|
||||
}
|
||||
|
||||
kebebCase(){
|
||||
const caseUtil = new CaseUtil();
|
||||
return caseUtil.toKebabCase(this.underlyingText);
|
||||
}
|
||||
|
||||
snakeCase(){
|
||||
const caseUtil = new CaseUtil();
|
||||
return caseUtil.toSnakeCase(this.underlyingText);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const wasim = new CaseWord("wasim est cool");
|
||||
const rachid = new CaseWord("rachid est cool");
|
||||
alert(wasim.kebebCase()); // wasim-est-cool
|
||||
alert(rachid.snakeCase()); // rachid_est_cool
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user