// a fn that return a string in both ways
const formatDate = (timestamp) => {
const date = new Date(timestamp);
// Concatenation using the + operator
return date.toLocaleDateString() + ' at ' + date.toLocaleTimeString();
// Using template literals
return `${date.toLocaleDateString()} at ${date.toLocaleTimeString()}`;
};
// let's create a dummy object
const note = {
title: 'Discuss project roadmap',
timestamp: Date.now(),
};
// Let's now output the function expression to the console using template literals
console.log(`Last edited: ${formatDate(note.timestamp)}`);