Using Split / The first field is not retrieved?

I have a database field that needs to be split into multiple lines delimited by the “|” symbol. I used spit to split the database field into multiple fields in an array. Then used field.length to determine how many fields resulted. Some of the database records may have only 2 or 3 while some have more than 25. Two fields are involved the model_usage field and the comments field. All works as expected with the exception of the very first field?

Webpage: CVOA Website then click on any thumbnail or thumbnail place holder. The field shows up in a corresponding lightbox.

Code:

// For full API documentation, including code examples, visit Velo API Reference - Wix.com
import {lightbox} from ‘wix-window’;

$w.onReady( () => {
let item = lightbox.getContext();
// console.log(item)
// console.log(“===========================================================REPEATER DATA===================================”)

let repimg = item.image_url;
let repdesc = item.description;
let reppart = item.oe_part_no;
let repapart = item.aftermkt_vendor_part_no;
let repinterchg = item.aftermkt_interchange;
let repcomments = item.comments;
let reptitle = item.title;
let repUsage = item.model_usage;

$w("#CVPartImg").src = repimg; 
$w("#LBdescription").text  = repdesc; 
$w("#LBoepartno").text = reppart; 
$w("#LBaftermkt").text = repapart; 
$w("#LBinterchange").text = repinterchg;     

// SPLIT THE COMMENTS FIELD
let input = repcomments;
let fields = input.split(‘|’);

let comments;
let i = 0;
while ( i < fields.length) {
comments = comments + “\n” + fields[i];
i = i + 1;
}
$w(“#LBcomments1”).text = comments;

//SPLIT MODEL USAGE FOR LBusage1
input = repUsage;
fields = input.split(‘|’);

let models;
i = 0;
while ( i < fields.length ) {
models = models + “\n” + fields[i];
i = i + 1;
}
$w(“#LBmodelUsage1”).text = models;

});

Resulting lightbox page:
What is wrong with this code?

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;