I am trying to make a simple form with typescript. I want to create an array of 'username password' each time I create a user.
export class Form{
username : string;
password : string;
isChecked : boolean;
arr: string[] = new Array();
constructor(){
this.isChecked = false;
}
signup(){
this.arr.push(this.username);
console.log(this.arr);
}
submit(){
var res = document.getElementById('check');
res.innerText = String(this.isChecked);
}
}
This code works but only with username when I check on the console but I want something that gives me arr[0] --> username, password and not only the username for example. I know it is something with the declaration of arr but I try other ways to declare it and I always get stuck.
[string, string][]? See typescriptlang.org/play/…[["username","password"]]? or maybe an array of object[{username:"foo",password:"bar"}]?