This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const yargs = require('yargs') | |
| const notes = require('./notes.js') | |
| // Customize yargs version | |
| yargs.version('1.1.0') | |
| // Create add command | |
| yargs.command({ | |
| command: 'add', | |
| describe: 'Add a new note', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| square = (x) => { | |
| return x * x | |
| } | |
| console.log(square(3)) | |
| const squares = (x) => x * x; | |
| console.log(squares(4)) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs') | |
| const dataBuffer = fs.readFileSync('person.json') | |
| const dataJSON = dataBuffer.toString() | |
| const user = JSON.parse(dataJSON) | |
| user.name = 'Gunther' | |
| user.age = 54 | |
| const userJSON = JSON.stringify(user) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require("fs"); | |
| const dataBuffer = fs.readFileSync("person.json") | |
| console.log(dataBuffer) | |
| console.log(dataBuffer.toString()) | |
| const dataJSON = dataBuffer.toString() | |
| const data = JSON.parse(dataJSON) | |
| console.log(data.title) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require("fs"); | |
| const book = { | |
| title: "Ego is the enemy", | |
| author: "Ryan Holiday" | |
| } | |
| const bookJson = JSON.stringify(book); | |
| fs.writeFileSync("1-person.json", bookJson) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const book = { | |
| title: "Ego is the enemy", | |
| author: "Ryan Holiday" | |
| } | |
| const bookJson = JSON.stringify(book); | |
| console.log(bookJson) | |
| const personData = JSON.parse(bookJson) | |
| console.log(personData.author) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const chalk = require("chalk"); | |
| console.log(chalk.blue("Success!")) | |
| const blueMessage = chalk.yellow("Succes!") | |
| console.log(blueMessage) | |
| const boldYellow = chalk.bold.yellow("Succes!") | |
| console.log(boldYellow) | |
| const boldInverse = chalk.bold.inverse.blue("Succes!") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const name = "Anmol" | |
| module.exports = name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.log("Anmol") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const add = function(a, b) { | |
| return a + b | |
| } | |
| module.exports = add |