Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 35 additions & 32 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
{
"files.exclude": {
".devcontainer": false,
".logs": false,
".vscode": false,
"bash": false,
"client": false,
"config": false,
"curriculum": false,
"node_modules": false,
"tooling": false,
".gitignore": false,
"freecodecamp.conf.json": false,
"package-lock.json": false,
"package.json": false,
"README.md": false,
"build-a-timestamp-microservice": false,
"build-a-web-server": false,
"learn-nodejs-repl": false,
"build-a-case-converter": false,
".devcontainer": true,
".logs": true,
".vscode": true,
"bash": true,
"client": true,
"config": true,
"curriculum": true,
"node_modules": true,
"tooling": true,
".gitignore": true,
"freecodecamp.conf.json": true,
"package-lock.json": true,
"package.json": true,
"README.md": true,
"build-a-timestamp-microservice": true,
"build-a-web-server": true,
"learn-nodejs-repl": true,
"build-a-case-converter": true,
"build-a-prime-number-checker-module": false,
"build-a-file-processor": false,
"build-a-family-movie-watchlist-api": false,
"build-a-random-joke-app": false,
"build-a-personal-profile-app": false,
"build-a-submission-form": false,
"build-a-data-sanitizer": false,
"build-a-weather-service-api": false,
"build-a-bank-api": false,
"build-a-resource-monitor": false,
"build-a-chat-app": false,
"build-jwt-protected-routes": false
"build-a-file-processor": true,
"build-a-family-movie-watchlist-api": true,
"build-a-random-joke-app": true,
"build-a-personal-profile-app": true,
"build-a-submission-form": true,
"build-a-data-sanitizer": true,
"build-a-weather-service-api": true,
"build-a-bank-api": true,
"build-a-resource-monitor": true,
"build-a-chat-app": true,
"build-jwt-protected-routes": true
},
"chat.disableAIFeatures": true,
"files.autoSave": "off",
Expand All @@ -42,15 +42,18 @@
"open": true,
"showLoader": true,
"timeout": 4000,
"url": "http://localhost:8080"
"url": "https://effective-bassoon-jgpgw6gr699hjgvx-8080.app.github.dev"
}
],
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
"args": ["--init-file", "./bash/sourcerer.sh"],
"args": [
"--init-file",
"./bash/sourcerer.sh"
],
"icon": "terminal-bash",
"path": "bash"
}
}
}
}
1 change: 1 addition & 0 deletions build-a-case-converter/case_converter/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
index.test.js
22 changes: 22 additions & 0 deletions build-a-case-converter/case_converter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Case Converter

This package is used to convert strings to a specific case..

## Installation

```bash
npm install case_converter
```

## Usage
```js
const caseConverter = require("./index");
const str = "hello free Code Camp!";
console.log(caseConverter.getUpperCase(str)); // HELLO FREE CODE CAMP!
console.log(caseConverter.getLowerCase(str)); // hello free code camp!
console.log(caseConverter.getProperCase(str)); // Hello Free Code Camp!
console.log(caseConverter.getSentenceCase(str)); // Hello free code camp!
```

## License
MIT license
40 changes: 40 additions & 0 deletions build-a-case-converter/case_converter/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const getUpperCase = (text) => {
const upperText = text.trim().toUpperCase();

return upperText;
};

const getLowerCase = (text) => {
const lowerText = text.trim().toLowerCase();

return lowerText;
};

const getSentenceCase = (text) => {

const first = getUpperCase(text[0]);
const rest = getLowerCase(text.slice(1,));
const sentence = `${first}${rest}`;

return sentence;
};

const getProperCase = (text) => {

let finalWords = "";
const words = text.split(" ");
words.map(word => {
finalWords += " " + getSentenceCase(word);
})

return finalWords.trim();
};

console.log(getProperCase("hello world"));

module.exports = {
getUpperCase,
getLowerCase,
getSentenceCase,
getProperCase
};
13 changes: 13 additions & 0 deletions build-a-case-converter/case_converter/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const assert = require("node:assert/strict");
const caseConverter = require("./index");

assert.strictEqual(
caseConverter.getUpperCase("hello free Code Camp!"),
"HELLO FREE CODE CAMP!",
);

assert.strictEqual(caseConverter.getLowerCase("hello free Code Camp!"), "hello free code camp!");

assert.strictEqual(caseConverter.getProperCase("hello free Code Camp!"), "Hello Free Code Camp!");

assert.strictEqual(caseConverter.getSentenceCase("hello free Code Camp!"), "Hello free code camp!");
18 changes: 18 additions & 0 deletions build-a-case-converter/case_converter/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "case_converter",
"version": "1.0.0",
"description": "Write This package is used to convert strings to a specific case",
"keywords": [
"case",
"converter",
"uppercase",
"lowercase"
],
"license": "MIT",
"author": "Armand",
"type": "commonjs",
"main": "index.js",
"scripts": {
"test": "node index.test.js"
}
}
5 changes: 5 additions & 0 deletions build-a-file-processor/assets/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Hello, freeCodeCamp!
Learning backend dev course
Learning backend dev course
Learning backend dev course
Learning backend dev course
3 changes: 3 additions & 0 deletions build-a-file-processor/assets/stream-output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Code in the browser,
Building projects, one by one,
Free for everyone.
90 changes: 90 additions & 0 deletions build-a-file-processor/server.js
Original file line number Diff line number Diff line change
@@ -1 +1,91 @@
// Starter file — add your code here
const fsPromises = require("fs/promises");
const fs = require(
"fs"
)

async function main() {
const data = await fsPromises.readFile("assets/poem.txt", {encoding: "utf8"});
console.log(data);
}

//main();

//fs.writeFileSync("assets/output.txt", "Hello, freeCodeCamp!");
//fs.appendFileSync("assets/output.txt", "\nLearning backend dev course");

const exists = fs.existsSync("assets/output.txt");
// console.log(exists);

// const entries = fs.readdirSync("assets");
// console.log(entries);

// const buf = Buffer.from("Hello, Node!");
// console.log(buf);
// console.log(buf.toString("hex"));
// console.log(buf.toString("base64"));

// const buf2 = Buffer.alloc(8, 0xff);
// console.log(buf2);

const decoded = Buffer.from("SGVsbG8=", "base64").toString("utf8");
console.log(decoded);

const crypto = require("crypto");
const hash = crypto.createHash("sha256").update("freeCodeCamp!").digest("hex");
console.log(hash);

const random = crypto.randomBytes(16).toString("hex");
console.log(random);

const id = crypto.randomUUID();
console.log(id);

const os = require("os");
console.log(os.platform());
console.log(os.arch());
console.log(os.hostname());
console.log(os.totalmem);
console.log(os.freemem());
console.log(os.uptime());
/*os.cpus() returns an array of objects describing each logical CPU core on the machine.
The number of cores is simply the length of that array:*/
console.log(os.cpus().length);

const path = require("path");
const fullPath = path.join(__dirname, "assets", "poem.txt");
console.log(fullPath);
console.log(path.basename(fullPath));
console.log(path.dirname(fullPath));
console.log(path.extname(fullPath));

console.log(path.join("assets", "..", "server.js"));
console.log(path.resolve("assets", "..", "server.js"));
const parts = path.parse("/home/user/assets/poem.txt");
console.log(parts);

console.log(process.version);
console.log(process.platform);
console.log(process.env);

console.log(process.argv);
console.log(process.argv[2]);

process.stdout.write("Hello from stdout\n");
process.stderr.write("Hello from stderr\n");

const readable = fs.createReadStream("assets/poem.txt", { encoding: "utf8" });

// readable.on("data", (chunk) => {
// console.log(chunk);
// });

// readable.on("end", () => {
// console.log("Done reading");
// });

const writable = fs.createWriteStream("assets/stream-output.txt");
// writable.write("First chunk\n");
// writable.write("Second chunk\n");
// writable.end();
readable.pipe(writable);
12 changes: 12 additions & 0 deletions build-a-prime-number-checker-module/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function isPrime(n) {
if (n <= 1)
return false;

// Check divisibility from 2 to n-1
for (let i = 2; i < n; i++)
if (n % i === 0)
return false;

return true;
}
module.exports = {isPrime};
16 changes: 16 additions & 0 deletions build-a-prime-number-checker-module/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "prime-number-checker-module",
"version": "1.0.0",
"description": "Check whether a number is prime or not.",
"keywords": [
"prime",
"non-prime"
],
"license": "MIT",
"author": "Armand",
"type": "commonjs",
"main": "index.js",
"scripts": {
"test": "index.test.js"
}
}
13 changes: 8 additions & 5 deletions config/projects.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,28 @@
"dashedName": "build-a-file-processor",
"isIntegrated": false,
"isPublic": true,
"currentLesson": 0,
"currentLesson": 29,
"runTestsOnWatch": true,
"seedEveryLesson": false,
"isResetEnabled": false,
"blockingTests": null,
"breakOnFailure": null,
"numberOfLessons": 30
"numberOfLessons": 30,
"completedDate": 1788205696760
},
{
"id": 2,
"dashedName": "build-a-case-converter",
"isIntegrated": false,
"isPublic": true,
"currentLesson": 0,
"currentLesson": 44,
"runTestsOnWatch": true,
"seedEveryLesson": false,
"isResetEnabled": false,
"blockingTests": null,
"breakOnFailure": null,
"numberOfLessons": 45
"numberOfLessons": 45,
"completedDate": 1788238447268
},
{
"id": 3,
Expand All @@ -49,7 +51,8 @@
"isResetEnabled": false,
"blockingTests": true,
"breakOnFailure": true,
"numberOfLessons": 1
"numberOfLessons": 1,
"completedDate": 1788242741961
},
{
"id": 4,
Expand Down
1 change: 1 addition & 0 deletions config/token.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyVG9rZW4iOiI1UE1YUHBxdUdsYzYzamNsUWllVXFxY1h2RmRmenNibFV5dzFSYTNjTEcwZ0dVbHRmbEdQbU1hNWlXY29DRHNTIiwiaWF0IjoxNzg4MjAwMjc5fQ.mD15elrnSZapvudWqyF3g7r21FxGPMoWJU3tCYPkW_0