Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proyecto terminado #75

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
46 changes: 46 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// One euro is:
let oneEuroIs = {
"JPY": 156.5, // japan yen
"USD": 1.07, // us dollar
"GBP": 0.87, // british pound
}


// Declaramos una función con el nombre exacto "formEuroToDollar"
const fromEuroToDollar = function(valueInEuro) {
// Convertimos el valor a dólares
let valueInDollar = valueInEuro * oneEuroIs.USD;
// Retornamos el valor en dólares
return valueInDollar;
}

// Funcion Yen
const fromDollarToYen = function(valueInDollar) {
// Convertimos el valor a Yenes
let valueInYen = valueInDollar / oneEuroIs.USD * oneEuroIs.JPY;
// Retornamos el valor en Yenes
return valueInYen;
}

// funcion Pound

const fromYenToPound = function (valueInYen) {
// Convertimos el valor a Pound
let valueInPound = valueInYen / oneEuroIs.JPY * oneEuroIs.GBP;
// Retornamos el valor en Pound
return valueInPound;
}



// Esta es mi función que suma dos números
const sum = (a,b) => {
return a + b
}

// Solo un registro en consola para nosotros
console.log(sum(7,3))

// Exporta la función para usarla en otros archivos
// (similar a la palabra clave "export" cuando se usa webpack)
module.exports = { sum, fromEuroToDollar, fromDollarToYen, fromYenToPound};
32 changes: 32 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Importar la función sum del archivo app.js
const { sum, fromDollarToYen, fromEuroToDollar, fromYenToPound} = require('./app.js');

// Comienza tu primera prueba
test('adds 14 + 9 to equal 23', () => {
// Dentro de la prueba llamamos a nuestra función sum con 2 números
let total = sum(14, 9);

// Esperamos que la suma de esos 2 números sea 23
expect(total).toBe(23);
});

test("One euro should be 1.07 dollars", function() {

// Hago mi comparación (la prueba)
expect(fromEuroToDollar(3.5)).toBe(3.745);
})

// test yen
test("One dolarr should be 156.5 yenes", function() {

// Hago mi comparación (la prueba)
expect(fromDollarToYen(3.5)).toBe(511.91588785046724);
})

// test Pound

test("One yen should be 0.87 pounds", function() {

// Hago mi comparación (la prueba)
expect(fromYenToPound(3.5)).toBe(0.019456869009584665);
})