-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2-logic-error.js
More file actions
37 lines (28 loc) · 996 Bytes
/
2-logic-error.js
File metadata and controls
37 lines (28 loc) · 996 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
// The syntax for this function is valid but it has an error, find it and fix it.
function trimWord(word) {
return wordtrim();
}
function getWordLength(word) {
return "word".length()
}
function multiply(a, b, c) {
a * b * c;
return;
}
/* ======= 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 2-logic-error` 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("fixed trimWord function", trimWord(" CodeYourFuture "), "CodeYourFuture");
test("fixed wordLength function", getWordLength("A wild sentence appeared!"), 25);
test("fixed multiply function", multiply(2, 3, 6), 36);