Could someone assist me with modifying my code so that the entered day is displayed at the end of all days in the console? Currently, it shows up at the top. Here is what I have tried:
JavaScript
const daysOfWeek = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"];
let currentDay = prompt("Enter day of week:");
while (!daysOfWeek.includes(currentDay)) {
currentDay = prompt("Invalid day. Enter day of week:").toLowerCase();
}
let currentDayPassed = false;
const daysLeft = [];
for (let i = 0; i < daysOfWeek.length; i++) {
if (daysOfWeek[i] === currentDay) {
currentDayPassed = true;
}
if (currentDayPassed) {
daysLeft.push(daysOfWeek[i]);
}
}
console.log(daysLeft);