Skip to content
This repository was archived by the owner on Oct 26, 2020. It is now read-only.

Commit c2c540c

Browse files
committed
extra:2-piping.js os done
1 parent f04cfa5 commit c2c540c

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

week-1/3-extra/2-piping.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,27 @@
1616
the final result to the variable goodCode
1717
*/
1818

19-
function add() {
19+
function add(a,b) {
20+
return a+b;
2021

2122
}
2223

23-
function multiply() {
24-
24+
function multiply(a,b) {
25+
return a*b;
2526
}
2627

27-
function format() {
28-
28+
function format(a) {
29+
return ${a}`;
2930
}
3031

31-
const startingValue = 2
32+
const startingValue = 2;
3233

3334
// Why can this code be seen as bad practice? Comment your answer.
34-
let badCode =
35+
let badCode = format((startingValue+10)*2);//no use of variables
3536

3637
/* BETTER PRACTICE */
3738

38-
let goodCode =
39+
let goodCode = badCode;//fisrt put result in variable and the assign to 2nd variable
3940

4041
/* ======= TESTS - DO NOT MODIFY =====
4142
There are some Tests in this file that will help you work out if your code is working.
@@ -46,17 +47,17 @@ To run these tests type `node 2-piping.js` into your terminal
4647
function test(test_name, expr) {
4748
let status;
4849
if (expr) {
49-
status = "PASSED"
50+
status = "PASSED";
5051
} else {
51-
status = "FAILED"
52+
status = "FAILED";
5253
}
5354

54-
console.log(`${test_name}: ${status}`)
55+
console.log(`${test_name}: ${status}`);
5556
}
5657

57-
test('add function - case 1 works', add(1,3) === 4)
58-
test('add function - case 2 works', add(2.4,5.3) === 7.7)
59-
test('multiply function works', multiply(2,3) === 6)
60-
test('format function works', format(16) === "£16")
61-
test('badCode variable correctly assigned', badCode === "£24")
62-
test('goodCode variable correctly assigned', goodCode === "£24")
58+
test('add function - case 1 works', add(1,3) === 4);
59+
test('add function - case 2 works', add(2.4,5.3) === 7.7);
60+
test('multiply function works', multiply(2,3) === 6);
61+
test('format function works', format(16) === "£16");
62+
test('badCode variable correctly assigned', badCode === "£24");
63+
test('goodCode variable correctly assigned', goodCode === "£24");

0 commit comments

Comments
 (0)