This might be very simple but I am trying to use the join() array in order to remove the - from the last item on the days array.
How can I do that? This is my code:
var days = [
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
'Sunday'
];
var counter = 0;
while (counter < days.length) {
document.write(days[counter]);
counter++;
days.join(' - ');
}
-? Can I see your html?.join()function returns a string. You just needdocument.write(days.join(","));and no loop.days.join().join(", ")days.join()in the loop, but do nothing with the returned string so it is a pointless line of code. Further, your question text refers to removing a-, but there is no such character in your code at all.