Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
andreybejarano committed Jun 3, 2022
0 parents commit af5492a
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
23 changes: 23 additions & 0 deletions clase5/app_tareas/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const funcTareas = require('./funcionesArchivos');

const accion = process.argv[2];

switch (accion) {
case 'listar':
const tareas = funcTareas.listar();
console.log('Listado de tareas');
console.log('-----------------');
for (let index = 0; index < tareas.length; index++) {
// console.log((index + 1) + '. ' + tareas[index].titulo + ' - ' + tareas[index].estado);
console.log(`${index + 1}. ${tareas[index].titulo} - ${tareas[index].estado}`);
}
break;
case undefined:
console.log('Atención - Tienes que pasar una acción.');
console.log('---------------------------------------');
break;
default:
console.log('No entiendo qué quieres hacer.');
console.log('------------------------------');
break;
}
9 changes: 9 additions & 0 deletions clase5/app_tareas/funcionesArchivos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Requiero la libreria fs
const fs = require('fs');

module.exports = {
listar: () => {
const fileTareas = fs.readFileSync('tareas.json', 'utf-8');
return JSON.parse(fileTareas);
}
}
14 changes: 14 additions & 0 deletions clase5/app_tareas/tareas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"titulo": "Repasar JS",
"estado": "terminada"
},
{
"titulo": "Armar apliación de tareas",
"estado": "en progreso"
},
{
"titulo": "Break",
"estado": "pendiente"
}
]
85 changes: 85 additions & 0 deletions clase5/arrays.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
const fruits = ['Manzana', 'Pera', 'Naranja'];

for (let index = 0; index < fruits.length; index++) {
console.log('Ciclo for: ', fruits[index]);
}

let index = 0;
while (index < fruits.length) {
console.log('Ciclo while: ', fruits[index]);
index++;
}

do {
console.log('Ciclo do while');
index++;
} while (index < fruits.length);

// console.log(fruits);

// fruits.push('Mandarina');

// console.log(fruits);

// fruits.unshift('Banana');

// console.log(fruits);

// fruits.pop();

// console.log(fruits);

// fruits.shift();

// console.log(fruits);

// const indexOfPera = fruits.indexOf('Pera');

// console.log(indexOfPera);

// const isPera = fruits.includes('Pera');

// console.log(isPera);


// console.log(fruits[fruits.length - 1]);

// const message = fruits.join(' -|- ');

// console.log(message);

// const found = true;
// const age = 18;

// const message = found || age > 18 ? 'Found' : 'Not found';

// const message2 = found || 'message 2';

// if (found) {
// message = 'Found'
// }

// console.log(message);























23 changes: 23 additions & 0 deletions clase6/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const funcTareas = require('./funcionesArchivos');

const accion = process.argv[2];

switch (accion) {
case 'listar':
const tareas = funcTareas.listar();
console.log('Listado de tareas');
console.log('-----------------');
for (let index = 0; index < tareas.length; index++) {
// console.log((index + 1) + '. ' + tareas[index].titulo + ' - ' + tareas[index].estado);
console.log(`${index + 1}. ${tareas[index].titulo} - ${tareas[index].estado}`);
}
break;
case undefined:
console.log('Atención - Tienes que pasar una acción.');
console.log('---------------------------------------');
break;
default:
console.log('No entiendo qué quieres hacer.');
console.log('------------------------------');
break;
}
9 changes: 9 additions & 0 deletions clase6/funcionesArchivos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Requiero la libreria fs
const fs = require('fs');

module.exports = {
listar: () => {
const fileTareas = fs.readFileSync('tareas.json', 'utf-8');
return JSON.parse(fileTareas);
}
}
14 changes: 14 additions & 0 deletions clase6/tareas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"titulo": "Repasar JS",
"estado": "terminada"
},
{
"titulo": "Armar apliación de tareas",
"estado": "en progreso"
},
{
"titulo": "Break",
"estado": "pendiente"
}
]

0 comments on commit af5492a

Please sign in to comment.