10-21-2018 06:34
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

10-21-2018 06:34
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi all, my JS skills aren't the best, so whilst I know the code to use for .split() and .match() commands, every time I use these I get a runtime error:
[2:26:27 PM]Unhandled TypeError: Expected a function.
- week at app/savedata.js:48,1
- filename at app/savedata.js:67,7
- createWorkout at app/buildWorkout.js:16,96
Is there a specific Import reference I need to add to get these functions to be supported?
Right now, I have
export let getDayFilename = function() { console.log(week.selectedDay); var date = week.selectedDay.split(" "); //Get the year var filename = date[3];
where week.selectedDay is "Mon Oct 15 2018 01:00:00 GMT+01:00". The console.log works fine, but then I get the error above.
Can someone help a confused noob out? Thanks 😉
FYI: I am ultimately converting the long date string from "Mon Oct 15 2018 01:00:00 GMT+01:00" to (e.g.) "2018-10-15" and using this as a file name.

10-22-2018 07:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


10-22-2018 07:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I think your code must be failing elsewhere. This works for me:
var week = {} week.selectedDay = "Mon Oct 15 2018 01:00:00 GMT+01:00"; var date = week.selectedDay.split(" "); //Get the year var filename = date[3]; console.log(filename); // 2018 ///////// or var newDate = new Date(week.selectedDay); console.log(newDate.getFullYear()); // 2018

