Content Creators Contracting

Hi!
First, I used the Visual Studio code to open the folder I just uncompressed, and found the request-logic.js file under the js folder.

Then I wrote:

function getContentType(filename) {

const extension = filename.match(/. .([^.] )$/)[1];

/ since it already gave you the variable ‘extension’ which will give you the last string, I figured just set the variable equal to what we want /

if (extension === ‘html’) {

return 'text/html';

} else if (extension === ‘css’) {

return 'text/css';

} else if (extension === ‘jpg’) {

return 'image/jpeg';

} else if (extension === ‘jpeg’) {

return 'image/jpeg';

} else {

return 'text/plain';

};

}
Then I ran the folder under Git Bash (right click the same folder and click Git Bash Here) and tested it using “npm run test”, this is what I got:

content-creators@1.0.0 test C:\Users\user\Downloads\project-0-content-creators-start
mocha

getContentType()
√ a function called getContentType should exist
√ should return “text/html” for filenames ending in .html
√ should return “text/css” for filenames ending in .css
√ should return “image/jpeg” for filenames ending in .jpeg
√ should return “image/jpeg” for filenames ending in .jpg
√ should return “text/plain” for all other file extensions

6 passing (6ms)

Finally I checked my demo (open the uncompressed folder and click the one name “index” with a chrome logo on it.) It worked just like the final version so I think I made it! I hope this help you guys too!

p.s. I am a high school student from Taiwan and I just joined this community recently! Please let me know if there’s any mistakes I made, whether it is coding-wise or some grammar mistakes during the interpretation! Have a great day coding y’all!