I want my for loop to print out every item in the array, not just the last item. Cant figure out where I'm going wrong:
var patients = ["Julia", "Kelly", "Thomas", "Clare"];
function lineOfPatients(line) {
if (!line.length) {
return "Empty"
}
for(var i = 0; i < line.length; i++) {
var list = `${i + 1}. ${line[i]},`
}
return `The line is currently: ${list}`
}
lineOfPatients(patients)
This returns "The line is currently: 4. Clare,"
I want it to return "The line is currently: 1. Julia, 2. Kelly, 3. Thomas, 4. Clare"