ncase / trust

An interactive guide to the game theory of cooperation
Creative Commons Zero v1.0 Universal
5.78k stars 922 forks source link

Add function to show current year in the intro text #88

Open maeriens opened 5 years ago

maeriens commented 5 years ago

This is to show the current year, addressing issue #68

I have literally no idea how I managed it, I simply copied more or less how the data was being replaced in the 2nd slide. I guess that's what people call programming.

nerdius commented 5 years ago

A better approach would be using a <span> with an unique ID, then selecting that from JavaScript and assigning a value to its innerHTML. There's also no need to have a function at all.

Here's the code:

HTML:

Meanwhile: it's <span id="current-year"></span>, the West has been at peace for decades, and

JavaScript:

document.querySelector('#current-year').innerHTML = new Date().getFullYear();