To fix Date.now().toISOString() throwing error "not a function" with JavaScript, we call toISOString on a date object.
For instance, we write
const now = new Date();
const isoString = now.toISOString();
to create a new Date object now.
Then we call now.toISOString to return the datetime string from the date.