Currently exploring typescript and aiming to construct a storage object.
The desired structure of the object is as follows:
workoutResults: array {
workoutResult {
dateOfWorkout: string
rounds: array {
sets:array {
repeats: number;
weight: number;
duration: number;
}
}
}
}
I intend to maintain a log of past workouts while also having access to the most recent workout results when initiating a new session.
While experimenting with interfaces, I encountered an issue:
interface WorkoutResult {
workoutDate: string;
workoutSet: WorkoutSet;
}
interface WorkoutSet {
}
export class WorkoutDoPage {
private workoutResults: Array<WorkoutResult>;
constructor(private nav: NavController, private navParams: NavParams, public exerciseData: ExerciseData) {
var testDate: any = new Date();
this.workoutResults.push(testDate);
console.log(this.workoutResults);
}
}
An error arises: Cannot read property 'push' of undefined.
Your guidance would be greatly appreciated :)
How can I effectively implement this data structure in typescript?