DASHA
This commit is contained in:
6
Объект global и глобальные переменные/app.js
Normal file
6
Объект global и глобальные переменные/app.js
Normal file
@@ -0,0 +1,6 @@
|
||||
const greeting = require('./greeting');
|
||||
|
||||
global.name = 'Dasha';
|
||||
|
||||
global.console.log(date);
|
||||
console.log(greeting.getMessage());
|
||||
10
Объект global и глобальные переменные/greeting.js
Normal file
10
Объект global и глобальные переменные/greeting.js
Normal file
@@ -0,0 +1,10 @@
|
||||
let currentDate = new Date();
|
||||
|
||||
global.date = currentDate;
|
||||
|
||||
module.exports.getMessage = function () {
|
||||
let hour = currentDate.getHours();
|
||||
if (hour > 16) return 'Добрый вечер, ' + global.name;
|
||||
else if (hour > 10) return 'Добрый день, ' + name;
|
||||
else return 'Доброе утро, ' + name;
|
||||
};
|
||||
Reference in New Issue
Block a user