Using Split / The first field is not retrieved?

PROBLEM SOLVED:
Did some Google searching on reasons for “undefined” in javascript and how to prevent them…
The “comments” field had no value so the concatenation of the field with the first element in the array casused the “undefined” … therefore in the loop:
comments = comments + fields[0]
resulted in “undefined” + the first element.

Modified code to initalize comments right after the split but before the loop and then starting the loop at index 1 instead of 0;

FIXED BY assigning the FIRST value for comments BEFORE the while loop started and initializing the loop to 1 instead of 0;

//SPLIT MODEL USAGE FOR LBusage1
let input = repUsage;
let models = “”;
let fields = input.split(‘|’);
models=fields[0];
//console.log(models)
i = 1;
while ( i < fields.length ) {
models = models + “\n” + fields[i];
// console.log(models)
i = i + 1;
}
$w(“#LBmodelUsage1”).text = models;