I have this node.js code:
var timeStamp = function() {
var d = new Date();
var year = d.getFullYear();
var month = d.getMonth() + 1;
var day = d.getDay();
var hours = d.getHours();
var minutes = d.getMinutes();
var seconds = d.getSeconds();
var milliseconds = d.getMilliseconds();
var time = year + '.' + month + '.' + day + '. ' + hours + ':' + minutes + ':' + seconds + ':' + milliseconds;
return time;
};
var tld = function() {
var domainExtensions = ['.com', '.org'];
for (var i=0; i<domainExtensions.length; i++) {
return domainExtensions[i];
}
};
// print process.argv
process.argv.forEach(function(val, index, array) {
console.log(index + ': ' + val + '' + tld() + ' █ ' + timeStamp());
});
This outputting:
$ node index.js one two=three four
0: C:\Program Files\nodejs\node.exe.com █ 2015.11.5. 13:45:18:187
1: c:\www\node\command-line-arguments\index.js.com █ 2015.11.5. 13:45:18:191
2: one.com █ 2015.11.5. 13:45:18:192
3: two=three.com █ 2015.11.5. 13:45:18:192
4: four.com █ 2015.11.5. 13:45:18:193
However what I want is to print in the console one console argument with every loop of array:
$ node index.js one two=three four
0: C:\Program Files\nodejs\node.exe.com █ 2015.11.5. 13:45:18:187
1: C:\Program Files\nodejs\node.exe.hu █ 2015.11.5. 13:45:18:187
2: c:\www\node\command-line-arguments\index.js.com █ 2015.11.5. 13:45:18:191
3: c:\www\node\command-line-arguments\index.js.hu █ 2015.11.5. 13:45:18:191
4: one.com █ 2015.11.5. 13:45:18:192
5: one.hu █ 2015.11.5. 13:45:18:192
6: two=three.com █ 2015.11.5. 13:45:18:192
7: two=three.hu █ 2015.11.5. 13:45:18:192
8: four.com █ 2015.11.5. 13:45:18:193
9: four.hu █ 2015.11.5. 13:45:18:193
Is there a way to achieve this?
Thank You for your help!