-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (33 loc) · 753 Bytes
/
index.js
File metadata and controls
41 lines (33 loc) · 753 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
38
39
40
41
/*jshint node: true, -W106 */
'use strict';
function buildHtml() {
return '<!DOCTYPE html><html><header><title>Hello World</title></header>'+
'<body><p>Hello World</p></body></html>';
}
console.log('Hello World');
var http = require('http');
var port = process.env.PORT || 3000;
http.createServer(function (req, res) {
var html = buildHtml();
res.writeHead(200, {
'Content-Type': 'text/html',
'Content-Length': html.length,
'Expires': new Date().toUTCString()
});
res.end(html);
}).listen(port);
module.exports = function(n) {
if (typeof n !== 'number') {
return null;
}
if (n % 3 === 0 && n % 5 === 0) {
return 'fizzbuzz';
}
if (n % 3 === 0) {
return 'fizz';
}
if (n % 5 === 0) {
return 'buzz';
}
return '' + n;
};