Skip to content
Open
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
13 changes: 13 additions & 0 deletions assignments/assignment_1/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
function getNameFromCommandLine() {
// Write you code here, name should be taken as args in process.argv
var Name=process.argv[process.argv.length-1];
return Name;
}

function getNameFromEnv() {
// Write your code here
var Name = process.env.name
return Name
}

function getNameFromReadLine() {
// Write your code here
const readline=require('readline')
const rl=readline.createInterface({
input:process.stdin,
output:process.stdout
})
rl.question("please enter your name",(name)=>{
console.log(name);
rl.close();
});
}

module.exports = {
Expand Down
9 changes: 9 additions & 0 deletions assignments/assignment_2/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html>
<head>
<title>Assignment2</title>
</head>
<body>
<h1>Hello World</h1>
</body>

</html>
8 changes: 8 additions & 0 deletions assignments/assignment_2/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const http=require("http")
const fs = require("fs");
const server = http.createServer((req, res) =>{
fs.readFile("index.html",{encoding: "utf-8"},(err,data)=>{
res.end(data);
})
})
server.listen(3000, ()=> console.log("server is responding"))
2 changes: 1 addition & 1 deletion tests/assignment_1.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { getNameFromCommandLine, getNameFromEnv } = require("../assignments/assignment_1");

describe('assignment_1', () => {
describe.only('assignment_1', () => {
const OLD_ARGV = process.argv;
const OLD_ENV = process.env;

Expand Down