Chapter 2: arrow functions
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
first(args, function () {
|
||||
second(args, function () {
|
||||
third(args, function () {});
|
||||
});
|
||||
});
|
||||
@@ -3,7 +3,7 @@ const path = require("path");
|
||||
|
||||
const filepath = path.join(process.cwd(), "hello.txt");
|
||||
|
||||
fs.readFile(filepath, "utf8", function (err, contents) {
|
||||
fs.readFile(filepath, "utf8", (err, contents) => {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
|
||||
@@ -3,14 +3,14 @@ const path = require("path");
|
||||
|
||||
const filepath = path.join(process.cwd(), "hello.txt");
|
||||
|
||||
fs.readFile(filepath, "utf8", function (err, contents) {
|
||||
fs.readFile(filepath, "utf8", (err, contents) => {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
console.log("File Contents:", contents);
|
||||
const upperContents = contents.toUpperCase();
|
||||
|
||||
fs.writeFile(filepath, upperContents, function (err) {
|
||||
fs.writeFile(filepath, upperContents, (err) => {
|
||||
if (err) throw err;
|
||||
console.log("File updated.");
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ const path = require("path");
|
||||
|
||||
const filepath = path.join(process.cwd(), "hello.txt");
|
||||
|
||||
fs.readFile(filepath, "utf8", function (err, contents) {
|
||||
fs.readFile(filepath, "utf8", (err, contents) => {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ const path = require("path");
|
||||
|
||||
const filepath = path.join(process.cwd(), "hello.txt");
|
||||
|
||||
fs.readFile(filepath, "utf8", function (err, contents) {
|
||||
fs.readFile(filepath, "utf8", (err, contents) => {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user