This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // La aplicación tiene que recibir argumentos a través de la terminal y mostrar un listado de películas basado en los argumentos que le hayas pasado. | |
| // Arquitectura | |
| // Tu aplicación debe tener estos 3 archivos: | |
| // index.js | |
| // Recibe argumentos, los procesa y delega las acciones a pelis.js. | |
| // pelis.js | |
| // Tiene que leer el archivo JSON y exponer funciones para interactuar con los datos. | |
| // pelis.json | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // Index.js | |
| // This file serves as the main entry point for the application. | |
| // This program perform the basic operations of addition, subtraction, multiplication, and division from the console, using argv to get the input values and operation type. | |
| const operaciones = require('./operaciones'); | |
| // This function is intended to parse text input from the console. | |
| function parcearTexto(texto) { | |
| // moks values for testing | |
| // return { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // Para este desafío, les proponemos trabajar con la metodología TDD. A partir de un test, deben crear una función que cuente cuántas palabras tiene el string que reciba y además devuelve cuantas palabras comienzan con la letra A. La función debe devolver un objeto con dos miembros: | |
| // Escribir acá la función cuentaPalabras | |
| function cuentaPalabras(texto) { | |
| // Dividir el texto en palabras usando el espacio como separador | |
| const palabras = texto.split(" "); | |
| // Contar la cantidad total de palabras | |
| const cantidadDePalabras = palabras.length; | |
| // Contar cuántas palabras comienzan con la letra "A" o "a" | |
| let palabrasConA = 0; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // Función original contarPalabras que cuenta palabras separadas por espacios marcando el error al contar espacios adicionales | |
| // function contarPalabras(texto) { | |
| // const palabras = texto.split(" "); | |
| // return palabras.length; | |
| // } | |
| // Versión corregida de la función contarPalabras usando trimmed para evitar contar espacios adicionales | |
| function contarPalabras(texto) { | |
| // Eliminamos espacios al inicio y final y separamos por uno o más espacios en blanco | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // contar.js | |
| // Function to count words in a phrase | |
| function contarPalabras(phrase) { | |
| console.log(phrase); | |
| numberOfWords = phrase.split(' ').length | |
| return numberOfWords | |
| } | |
| // If you use this code instead of the one above, the test will fail, because the expected output is different, changing slice to split | |
| // function contarPalabras(phrase) { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // index.js | |
| // Import the suma function and the test function for testing purposes | |
| const suma = require('./suma.js'); | |
| const test = require('./test.js'); | |
| function main() { | |
| console.log('Sum´s result: ' + suma(2, 10)); | |
| test(); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /* Ejercicio 13: función que reciba un array de argumentos introducidos desde la terminal con este formato: | |
| node index.js --argument valor --otro-argumento otro-valor --tercer-argumento 80 | |
| Además, esa función tiene que devolver el array de argumentos convertido en un objeto, por lo tanto, tiene que tener este formato: | |
| { | |
| "argumento":"valor", | |
| "otro-argumento":"otro-valor", | |
| (etc…) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const readline = require("readline"); | |
| const rl = readline.createInterface({ | |
| input: process.stdin, | |
| output: process.stdout, | |
| }); | |
| let score = 0; | |
| let index = 0; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function transformarFrase(frase) { | |
| const fraseMayuscula = frase.map((palabra) => { | |
| let inicial = palabra.charAt(0); // Obtener la primera letra | |
| let inicialMayuscula = inicial.toUpperCase(); // Convertir a mayúscula | |
| let resto = palabra.slice(1).toLowerCase(); // Obtener el resto en minúscula | |
| return inicialMayuscula + resto; // Devolver la nueva palabra | |
| }); | |
| const oracion = fraseMayuscula.join(" "); // Unir las palabras | |
| return oracion; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function main(){ | |
| const arr = ["hola", "adios", "bienvenido", "chau"]; | |
| console.log(filterByLength(arr, 5)); // debería imprimir ["adios", "bienvenido"] | |
| } | |
| function filterByLength (array, number){ | |
| const newArray = []; | |
| for (const word of array) { | 
NewerOlder