Create prototype for title casing
This commit is contained in:
parent
f75a897648
commit
168961e779
2 changed files with 13 additions and 0 deletions
|
|
@ -11,6 +11,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
// Import Misc JS things
|
||||||
|
import "./js/prototypes.js";
|
||||||
|
|
||||||
// Import components
|
// Import components
|
||||||
import LoginCard from './components/LoginView.vue';
|
import LoginCard from './components/LoginView.vue';
|
||||||
import MainView from './components/MainView.vue';
|
import MainView from './components/MainView.vue';
|
||||||
|
|
|
||||||
10
src/js/prototypes.js
vendored
Normal file
10
src/js/prototypes.js
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
String.prototype.toTitleCase = function () {
|
||||||
|
let words = this.split(` `);
|
||||||
|
let new_words = [];
|
||||||
|
for (var word of words) {
|
||||||
|
new_words.push(
|
||||||
|
`${word[0].toUpperCase()}${word.slice(1).toLowerCase()}`
|
||||||
|
);
|
||||||
|
};
|
||||||
|
return new_words.join(` `);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue