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 starter-code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
32 changes: 32 additions & 0 deletions starter-code/calculadora.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Initial code
const readlineSync = require('readline-sync');
const {sum, Subtraccion, Multiplication, Division} = require ('./math');


const operations = ['sum', 'Substraction','Multiplication', 'Division' ];
const index = readlineSync.keyInSelect( operations, 'Witch operations do you want');
let firtsNumber
let secondNumber
if (index != -1) {
firtsNumber = readlineSync.questionInt('Input firts number: ');
secondNumber = readlineSync.questionInt('Input second number: ');
}

switch(index) {
case 0:
console.log(sum(firtsNumber, secondNumber));
break;
case 1:
console.log(Substraction(firtsNumber, secondNumber));
break;
case 2:
console.log(Multiplication(firtsNumber, secondNumber));
break;
case 3:
console.log(Division(firtsNumber, secondNumber));
break;
default:
console.log('Nothing!');
break;
}

23 changes: 22 additions & 1 deletion starter-code/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
// Initial code
console.log('Welcome to Node.js');
const http = require ('http');

// Creating server

// const server = http.createServer((req, res) => {
// res.end('Bienvenidos a Node.js!');
// })

// Server listening

// server.listen('8080')

http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'Text/html' });

res.end('<p>Bienvenidos a Node.js!</p><h2>Subtitle</h2>');
})
.listen('8080')

console.log('Node Application listening on port 8080');


25 changes: 25 additions & 0 deletions starter-code/math.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Const Module

// Sum
const sum = (x , y) => x + y;

// Subtraccion

const Subtraccion = (x , y) => x - y;

// Multiplication

const Multiplication = (x , y) => x * y;

// Division

const Division = (x , y) => x / y;


module.exports = {
sum,
Subtraccion,
Multiplication,
Division,

};
13 changes: 13 additions & 0 deletions starter-code/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion starter-code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"version": "0.0.1",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"readline-sync": "^1.4.9"
}
}
}