Small updates

This commit is contained in:
Federico Kereki
2018-11-26 22:06:55 -03:00
parent b9ad15af2e
commit 50e2658b27
3 changed files with 596 additions and 606 deletions
+19
View File
@@ -0,0 +1,19 @@
function showAge(strings, name, year) {
const currYear = new Date().getFullYear();
const yearsAgo = currYear - year;
return (
strings[0] + name + strings[1] + year + `, ${yearsAgo} years ago`
);
}
const who = "Prince Valiant";
const when = 1937;
const output1 = showAge`The ${who} character was created in ${when}.`;
console.log(output1);
// The Prince Valiant character was created in 1937, 81 years ago
const model = "Suzuki";
const yearBought = 2009;
const output2 = showAge`My ${model} car was bought in ${yearBought}`;
console.log(output2);
// My Suzuki car was bought in 2009, 9 years ago