Arrays + loops = superpower
A teacher calling the register goes through every name, one by one. Loops and arrays were made for each other — let's visit every item in a list.
for…of: the friendly way
const students = ["Asha", "Bikash", "Chandra"];
for (const name of students) {
console.log("Present: " + name);
}If you need the position as well, use a counting for loop up to length:
const students = ["Asha", "Bikash", "Chandra"];
for (let i = 0; i < students.length; i++) {
console.log(`${i + 1}. ${students[i]}`);
}