-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathsolved.js
More file actions
43 lines (37 loc) · 952 Bytes
/
solved.js
File metadata and controls
43 lines (37 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function extraerTitulos(notas) {
return notas.map(nota => nota.title);
}
function agregarFechaCreacion(notas) {
return notas.map(nota => ({
...nota,
fechaCreacion: Date.now()
}));
}
function filtrarFavoritas(notas) {
return notas.filter(nota => nota.esFavorita);
}
function buscarPorTitulo(notas, busqueda) {
const terminoBusqueda = busqueda.toLowerCase();
return notas.filter(nota =>
nota.title.toLowerCase().includes(terminoBusqueda)
);
}
function aplicarDescuento(productos, porcentajeDescuento) {
return productos.map(producto => ({
...producto,
precioFinal: producto.precio * (1 - porcentajeDescuento / 100)
}));
}
function filtrarPorRango(productos, min, max) {
return productos.filter(producto =>
producto.precio >= min && producto.precio <= max
);
}
module.exports = {
extraerTitulos,
agregarFechaCreacion,
filtrarFavoritas,
buscarPorTitulo,
aplicarDescuento,
filtrarPorRango,
};