This repository was archived by the owner on Oct 26, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy path1-syntax-errors.js
More file actions
48 lines (31 loc) · 1.23 KB
/
1-syntax-errors.js
File metadata and controls
48 lines (31 loc) · 1.23 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
41
42
43
44
45
46
47
48
// There are syntax errors in this code - can you fix it to pass the tests?
function addNumbers(a, b ,c) {
return a + b + c;
}
function introduceMe(name, age){
return `Hello, my name is ${name} and I am ${age} years old`
}
function getTotal(a, b) {
total = a + b;
// Use string interpolation here
return `The total is ${total}`
}
/* ======= 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-syntax-errors.js` into your terminal
*/
const util = require('util');
/* ======= TESTS - DO NOT MODIFY ===== */
// To run these tests type `node 1-syntax-errors.js` into your terminal
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("fixed addNumbers function - case 1", addNumbers(3, 4, 6), 13);
test("fixed introduceMe function", introduceMe("Sonjide", 27), "Hello, my name is Sonjide and I am 27 years old");
test("fixed getTotal function", getTotal(23, 5), "The total is 28");