freeCodeCamp/utils/block-nameify.js
Randell Dawson 06da30e48a feat(learn): Basic CSS Cafe Menu instructions and hints/tests (v7) (#39407)
* feat: created step instructions for cafe menu

fix: added instructions to steps 1-31

fix: changed steps 29-31

fix: added instructions for steps 32-42

fix: changed prototype class definition

fix: padded file names

fix: added instructions for steps 43-61

fix: add object id to final.md and final prototype to meta.json

fix: correct typos in steps 26 and 27

fix: misc wording changes

fix: added forward slash to closing html tag

fix: added instructions for steps 62-75

feat: added instructions to steps 76-79

fix: added FOOTER comment for steps 68-75

fix: add steps 68a and 68b

fix: add steps 69a and reorder steps

fix: added instructions to the final steps

* fix: remove final.md

* fix: fixed typo of menue to menu

Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>

* fix: changed wording to improve readability

Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>

* fix: changed wording to improve readability

Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>

* fix: changed wording to improve readability

Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>

* fix: combined two lines into same paragraph

Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>

Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>
2020-09-16 11:54:13 +05:30

50 lines
1.7 KiB
JavaScript

const preFormattedBlockNames = {
'api-projects': 'API Projects',
'basic-css': 'Basic CSS',
'basic-html-and-html5': 'Basic HTML and HTML5',
'css-flexbox': 'CSS Flexbox',
'css-grid': 'CSS Grid',
devops: 'DevOps',
es6: 'ES6',
'information-security-with-helmetjs': 'Information Security with HelmetJS',
jquery: 'jQuery',
'json-apis-and-ajax': 'JSON APIs and Ajax',
'mongodb-and-mongoose': 'MongoDB and Mongoose',
'the-dom': 'The DOM',
'apis-and-microservices': 'APIs and Microservices',
'apis-and-microservices-projects': 'APIs and Microservices Projects',
'scientific-computing-with-python': 'Scientific Computing with Python',
'data-analysis-with-python': 'Data Analysis with Python',
'machine-learning-with-python': 'Machine Learning with Python',
tensorflow: 'TensorFlow',
'basic-javascript-rpg-game': 'Basic JavaScript RPG Game',
'basic-html-cat-photo-app': 'HTML Cat Photo App',
'basic-css-cafe-menu': 'CSS Cafe Menu',
'css-variables-skyline': 'CSS Variables Skyline',
'javascript-spreadsheet': 'JavaScript Spreadsheet',
'intermediate-javascript-calorie-counter':
'Intermediate JavaScript Calorie Counter',
'd3-dashboard': 'D3 Dashboard'
};
const noFormatting = ['and', 'for', 'of', 'the', 'up', 'with'];
exports.blockNameify = function blockNameify(phrase) {
const preFormatted = preFormattedBlockNames[phrase] || '';
if (preFormatted) {
return preFormatted;
}
return phrase
.split('-')
.map(word => {
if (noFormatting.indexOf(word) !== -1) {
return word;
}
if (word === 'javascript') {
return 'JavaScript';
}
return word.charAt(0).toUpperCase() + word.slice(1);
})
.join(' ');
};