Displaying names from array on different text fields in a loop

Have have an array of names and a bunch of text fields labeled 0, 1, 2, etc on a page.
I’m trying to change the text on the text fields to the corresponding items number in the array.

After troubleshooting and getting the value of the text fields to change correctly, the text on the page will not update.

Here is my code for the loop -

export function displaynames ( arr , size ){
var statement = ‘$w("#’ + i + ‘").text’
for ( var i = 0 ; i < size ; i ++){
var user = arr [i]
statement = user
}

the variable size is the amount of rows in the dataset I’m using (So its equal to 2).
The array has 2 names in it.

Not sure if I have to do some kind of update after I change the value of the text or if its just a small bug with wix. any information would be greatly appreciated, Thanks!

There are a couple of things wrong in your code. Does not matter, we have all been there. But you can and should try to find the problems yourself, that way you learn. SO might I suggest putting in a console.log after every line, so you can inspect what is going on. You’ll find the errors and you have gained some experience.
Example:

console.log("statement=" + statement); // put this right after the var statement = 

I bet, in this case, it returns “undefined”.