Node exercises solved during Skylab Coders Academy's MEAN Stack bootcamp
Write a node.JS program that execute a connection to server and return success message like "Success, i'm listening from port: 3000"
Hint: Yo u need npm module - http
### Extra
Set the port of the connection using an environment variable PORT
Write a node program that read a file (passed as parameter) in local machine and shows in the console the content of it.
node app.js test.txt
Hint: You need npm module - fs
Write a node.JS program that read and shows in the console the html code of one external page. The link of the external page should be read from a file link.txt
Hint: You need npm module -> request
##4. File list
Write a node.JS program that list the content of the current directory indicating if is a directory or a file
$ node ex4.js
FILE:ex1.js
FILE:ex2.js
FILE:ex3.js
FILE:ex4.js
FILE:getLinksNode.js
FILE:link.txt
DIR :node_modules
FILE:recursiveContentsDir.js
FILE:results.txt
FILE:test.txt
Hint: You need fs.readdirSync
, fs.lstatSync
and isDirectory()
Write a node.JS program that creates a txt file with the text passed as a parameter
$ node ex5.js "hey ho! let's go"
The file was saved!
$ cat myText.txt
hey ho! let's go
Hint: You need fs.writeFile
Improve the previous exercise to user the first parameter as the name of the destination file
Improve the previous exercise to also read and shows in the console the content of the file
$ node ex5.js mySuperText.txt "it's a long way to the top..."
The file was saved!
it's a long way to the top...
$ cat mySuperText.txt
it's a long way to the top...
Write a node program that process local txt and return values as a Array.
Hint: You need npm module -> concat-stream
Write a node program that read the page https://nodejs.org/api/all.html
and writes in a file (and shows it content after reading it) the internal links that contain some text passed as a parameter.
$ node getLinksNode.js createServer
The file was saved!
https://nodejs.org/api/all.html#http_http_createserver_requestlistener
https://nodejs.org/api/all.html#https_https_createserver_options_requestlistener
https://nodejs.org/api/all.html#net_net_createserver_options_connectionlistener
https://nodejs.org/api/all.html#tls_tls_createserver_options_secureconnectionlistener
$ node getLinksNode.js readFile
The file was saved!
https://nodejs.org/api/all.html#fs_fs_readfile_file_options_callback
https://nodejs.org/api/all.html#fs_fs_readfilesync_file_options
##8. Show Hour Write a node.JS program that shows you the local hour of server.
Hint: You need npm module -> strftime
##9. Compare values Write a node.JS program that search information in .txt file and returns you how much coincidences find.
If you search about "John", and in your txt files are 2 John, should return 2
Hint: You can try save all data in one array and compare with search..
##10. Saving Write a node.JS program that sum all integers saved in other txt file.
##11. Creating HTML Write a node.JS program that create a HTML file. Access this HTML with http://localhost:8080 from your browser
Hint: You need npm module -> html
##12. Creating HTML II Write a node.JS program that create a HTML file with a JavaScript function inside that say: "Hello!" Access this HTML with http://localhost:8080 from your browser
Hint: You need npm module -> html
##13. JSON Write a node.JS program that read a JSON file and show you some propierties for console.
JSON FILE:
{
"username":"xyz",
"password":"xyz@123"
"email":"[email protected]",
"id": 0001
}
Read username, password, email and id,
Write a node.JS program that read a JSON object and show the propierties for console
Write a node.JS program that read a JSON file and delete one propierty.
Write a node.JS program that read a JSON file and show you some propierties for console with itinerate values
Write a node.JS program that read a JSON file and compare if propierties exist in JSON file.
Write a node.JS program that read two JSON files and compare if propierties are same in both files and show success message when the comparation it's over.
Hint:
if(typeof o1[keyPair[0]] == typeof o2[keyPair[1]] == "object") {
return deepEquals(o1[keyPair[0]], o2[keyPair[1]])
} else {
return o1[keyPair[0]] == o2[keyPair[1]];