forked from sgrouples/javascript-assignment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex09.js
36 lines (22 loc) · 941 Bytes
/
ex09.js
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
/*
Use Function#bind to implement a logging function that allows you to namespace messages.
Your implementation should take a namespace string, and return a function that prints messages to the console with the namespace prepended.
Make sure all arguments passed to the returned logging function are printed.
Print the output to the console directly
Arguments
* namespace: a String to prepend to each message passed to the returned function.
Example
var info = logger('INFO:')
info('this is an info message')
// INFO: this is an info message
var warn = logger('WARN:')
warn('this is a warning message', 'with more info')
// WARN: this is a warning message with more info
Conditions
* Use Function#bind
*/
function logger(namespace) {
return console.log.bind(undefined, namespace);
}
var info = logger('INFO:');
info('Some important information', 'with more info', 'and even more info');