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 path3-function-output.js
More file actions
53 lines (43 loc) · 1.59 KB
/
3-function-output.js
File metadata and controls
53 lines (43 loc) · 1.59 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
49
50
51
52
53
// Add comments to explain what this function does. You're meant to use Google!
function getNumber() {//MAth.random()*10 return random numbers between 1 and 10
return Math.random() * 10;
}
// Add comments to explain what this function does. You're meant to use Google!
function s(w1, w2) {//w1.concat(w2) return a new string containing the text of joined string
return w1.concat(w2);
}
function concatenate(firstWord, secondWord, thirdWord) {
console.log(firstWord.concat(" ").concat(secondWord).concat(" ").concat(thirdWord));
return firstWord.concat(" ").concat(secondWord).concat(" ").concat(thirdWord);
// Write the body of this function to concatenate three words together.
// Look at the test case below to understand what this function is expected to 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 3-function-output` 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(
"concatenate function - case 1 works",
concatenate('code', 'your', 'future'),
"code your future"
);
test(
"concatenate function - case 2 works",
concatenate('I', 'like', 'pizza'),
"I like pizza"
);
test(
"concatenate function - case 3 works",
concatenate('I', 'am', 13),
"I am 13"
);