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
1 change: 1 addition & 0 deletions modulo4/node-package-json/.gitignore.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/node_modules
8 changes: 8 additions & 0 deletions modulo4/node-package-json/exercicio1/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
a) Responda como comentário no seu código: como fazemos para acessar os parâmetros passados na linha de comando para o Node?

R: Utilizamos o process.argv[2 ou mais]
*/

console.log(`Olá ${process.argv[2]}! você têm ${process.argv[3]} anos.`)
console.log(`Você terá ${+(process.argv[3]) + 7} daqui a 7 anos.`)
14 changes: 14 additions & 0 deletions modulo4/node-package-json/exercicio1/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "exercicio1",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"keywords": [],
"author": "",
"license": "ISC"
}
13 changes: 13 additions & 0 deletions modulo4/node-package-json/exercicio2/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const mathFunc = (op, num1, num2)=>{
if(op == "add"){
return num1 + num2
} else if(op == "sub"){
return num1 - num2
} else if(op == "mult"){
return num1 * num2
} else if(op == "div"){
return num1 / num2
}
}

console.log(mathFunc(process.argv[2],+(process.argv[3]),+(process.argv[4])))
15 changes: 15 additions & 0 deletions modulo4/node-package-json/exercicio2/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "exercicio2",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"keywords": [],
"author": "",
"license": "ISC"
}

5 changes: 5 additions & 0 deletions modulo4/node-package-json/exercicio3/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const toDo = ['estudar', 'trabalhar']
toDo.push(process.argv[2])
const toDoList = toDo.map(i => ` ${i}`)

console.log(`Tarefa adicionada com sucesso! Lista de tarefas:${toDoList.join(" |")}.`)
15 changes: 15 additions & 0 deletions modulo4/node-package-json/exercicio3/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "exercicio3",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"keywords": [],
"author": "",
"license": "ISC"
}