-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHW 000000002
70 lines (63 loc) · 1.66 KB
/
HW 000000002
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/**
* This is a question with two parts.
*
* PART 1
* Create a function called "printer".
* Given a student name, it should format and prints out the value in a visually appealing way
* (e.g. with hyphens or asterisks before each value) with `console.log`
* slide
* @example
* - Jamal
* - Matina
* @param {string} name instructor name
*/
// WRITE PART 1 OF YOUR ANSWER HERE
/**
* PART 2
* NOTE that the test will use the "printer" function that you completed in the problem above.
* Loop through the array of strings.
* For each name, calls upon the function "printer" to print out the name
* @param {array}
* @param {function} callback printer function
*
* @example
* printNames(["Jamal", "Matina"], printer);
* // - Jamal
* // - Matina
*/
const printNames = (array, callback) => {
// WRITE PART 2 OF YOUR ANSWER HERE
};
const printer = (name) => {
console.log(`- ${name}\n`);
};
/**
* PART 2
* NOTE that the test will use the "printer" function that you completed in the problem above.
* Loop through the array of strings.
* For each name, calls upon the function "printer" to print out the name
* @param {array}
* @param {function} callback printer function
*
* @example
* printNames(["Jamal", "Matina"], printer);
* // - Jamal
* // - Matina
*/
const printNames = (array, callback) => {
// WRITE PART 2 OF YOUR ANSWER HERE
for (let item of array) {
callback(item);
}
};
// IGNORE THIS BELOW. It is for the tests.
const myExports = {
printer: undefined,
printNames,
};
try {
//eslint-disable-next-line no-undef
if (printer) myExports.printer = printer;
// eslint-disable-next-line no-undef
} catch (e) {}
export default myExports;