-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5-currency-conversion.js
More file actions
40 lines (31 loc) · 1.24 KB
/
5-currency-conversion.js
File metadata and controls
40 lines (31 loc) · 1.24 KB
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
/*
CURRENCY FORMATTING
===================
The business is breaking out into a new market and need to convert prices to USD
Write a function that converts a price to USD (exchange rate is 1.4 $ to £)
*/
function convertToUSD() {}
/*
CURRENCY FORMATTING
===================
The business is now breaking into the Brazilian market
Write a new function for converting to the Brazilian real (exchange rate is 5.7 BRL to £)
They have also decided that they should add a 1% fee to all foreign transactions, which means you only convert 99% of the £ to BRL.
*/
function convertToBRL() {}
/* ======= TESTS - DO NOT MODIFY =====
There are some Tests in this file that will help you work out if your code is working.
To run these tests type `node 1-currency-conversion` into your terminal
*/
const util = require('util');
function test(test_name, actual, expected) {
let status;
if (actual === expected) {
status = "PASSED";
} else {
status = `FAILED: expected: ${util.inspect(expected)} but your function returned: ${util.inspect(actual)}`;
}
console.log(`${test_name}: ${status}`);
}
test("convertToUSD function works", convertToUSD(32), 44.8);
test("convertToBRL function works", convertToBRL(30), 169.29);