Problem initializing the array (TypeScript)

I am trying to copy the properties of an object (response.projects)[i].name) to an array. I have the following:

Answer => {
if (response.projects) {

this.projects = answer.projects;

console.log (this.projects[0]);
for (var i = 0; i <response.projects.length; i ++) {

if (type of these projects[i].Surname! = "undefined") {
this.names[i]= these.projects[i].Surname;

However, I get the error message "Property 0 of undefined can not be set", probably related to this.names[0], I do not know how to write the code to work, thank you!