udemy-node-tests/utils/utils.js

21 lines
438 B
JavaScript
Raw Normal View History

2017-11-29 03:14:07 +00:00
module.exports.add = (a, b) => a + b;
module.exports.asyncAdd = (a, b, callback) => {
setTimeout(() => {
callback(a + b);
}, 50);
}
module.exports.square = (x) => x * x;
module.exports.asyncSquare = (a, callback) => {
setTimeout(() => {
callback(a * a);
}, 50);
}
module.exports.setName = (user, fullName) => {
var names = fullName.split(" ");
user.firstName = names[0];
user.lastName = names[1];
return user;
}